8、使用磁带机
查看机械手状态:
[root@ www.linuxidc.com ~]# mtx -f /dev/sg10 status
- Storage Changer /dev/sg10:4 Drives, 43 Slots ( 4 Import/Export )
- Data Transfer Element 0:Empty
- Data Transfer Element 1:Empty
- Data Transfer Element 2:Empty
- Data Transfer Element 3:Empty
- Storage Element 1:Full :VolumeTag=E01001L4
- Storage Element 2:Full :VolumeTag=E01002L4
- Storage Element 3:Full :VolumeTag=E01003L4
- Storage Element 4:Full :VolumeTag=E01004L4
- Storage Element 5:Full :VolumeTag=E01005L4
- Storage Element 6:Full :VolumeTag=E01006L4
- Storage Element 7:Full :VolumeTag=E01007L4
- Storage Element 8:Full :VolumeTag=E01008L4
- Storage Element 9:Full :VolumeTag=E01009L4
- Storage Element 10:Full :VolumeTag=E01010L4
- Storage Element 11:Full :VolumeTag=E01011L4
- Storage Element 12:Full :VolumeTag=E01012L4
- Storage Element 13:Full :VolumeTag=E01013L4
- Storage Element 14:Full :VolumeTag=E01014L4
- Storage Element 15:Full :VolumeTag=E01015L4
- Storage Element 16:Full :VolumeTag=E01016L4
- Storage Element 17:Full :VolumeTag=E01017L4
- Storage Element 18:Full :VolumeTag=E01018L4
- Storage Element 19:Full :VolumeTag=E01019L4
- Storage Element 20:Full :VolumeTag=E01020L4
- Storage Element 21:Empty
- Storage Element 22:Full :VolumeTag=CLN101L4
- Storage Element 23:Full :VolumeTag=CLN102L5
- Storage Element 24:Empty
- Storage Element 25:Empty
- Storage Element 26:Empty
- Storage Element 27:Empty
- Storage Element 28:Empty
- Storage Element 29:Empty
- Storage Element 30:Full :VolumeTag=F01030L5
- Storage Element 31:Full :VolumeTag=F01031L5
- Storage Element 32:Full :VolumeTag=F01032L5
- Storage Element 33:Full :VolumeTag=F01033L5
- Storage Element 34:Full :VolumeTag=F01034L5
- Storage Element 35:Full :VolumeTag=F01035L5
- Storage Element 36:Full :VolumeTag=F01036L5
- Storage Element 37:Full :VolumeTag=F01037L5
- Storage Element 38:Full :VolumeTag=F01038L5
- Storage Element 39:Full :VolumeTag=F01039L5
- Storage Element 40 IMPORT/EXPORT:Empty
- Storage Element 41 IMPORT/EXPORT:Empty
- Storage Element 42 IMPORT/EXPORT:Empty
- Storage Element 43 IMPORT/EXPORT:Empty
将磁带从1号槽位装入driver 0:
[root@ www.linuxidc.com ~]# mtx -f /dev/sg10 load 1 0
- Loading media from Storage Element 1 into drive 0...done
- [root@ www.linuxidc.com ~]# mtx -f /dev/sg10 status
- Storage Changer /dev/sg10:4 Drives, 43 Slots ( 4 Import/Export )
- Data Transfer Element 0:Full (Storage Element 1 Loaded):VolumeTag = E01001L4
- Data Transfer Element 1:Empty
- Data Transfer Element 2:Empty
- Data Transfer Element 3:Empty
- Storage Element 1:Empty
查看磁带状态:
[root@ www.linuxidc.com ~]# mt -f /dev/st0 status
- SCSI 2 tape drive:
- File number=0, block number=0, partition=0.
- Tape block size 0 bytes. Density code 0x48 (Quantum SDLT220).
- Soft error count since last status=0
- General status bits on (41010000):
- BOT ONLINE IM_REP_EN
[root@ www.linuxidc.com ~]# tar -cvvf /dev/st0 mhvtl-0.18/
- drwxr-xr-x root/root 0 2012-08-16 16:29 mhvtl-0.18/
- drwxr-xr-x 1000/1000 0 2010-06-22 15:40 mhvtl-0.18/man/
- -rw-r--r-- 1000/1000 1309 2009-12-17 04:52 mhvtl-0.18/man/mhvtl.conf.5
- -rw-r--r-- 1000/1000 1081 2009-12-17 04:52 mhvtl-0.18/man/build_library_config.1
- -rw-r--r-- 1000/1000 2303 2009-12-17 04:52 mhvtl-0.18/man/vtlcmd.1
- -rw-r--r-- 1000/1000 3328 2009-12-17 04:52 mhvtl-0.18/man/mhvtl.1
- -rw-r--r-- 1000/1000 1371 2009-12-17 04:52 mhvtl-0.18/man/mktape.1
- -rw-r--r-- 1000/1000 888 2009-12-17 04:52 mhvtl-0.18/man/make_vtl_devices.1
- -rw-r--r-- 1000/1000 1599 2009-12-17 04:52 mhvtl-0.18/man/vtllibrary.1
- -rw-r--r-- 1000/1000 1380 2009-12-17 04:52 mhvtl-0.18/man/vtltape.1
- -rw-r--r-- 1000/1000 3182 2010-06-22 15:38 mhvtl-0.18/man/device.conf.5
- -rw-r--r-- 1000/1000 1460 2010-06-22 15:38 mhvtl-0.18/man/library_contents.5
- -rw-r--r-- 1000/1000 2217 2010-06-15 04:15 mhvtl-0.18/Makefile
- drwxr-xr-x 1000/1000 0 2012-08-16 16:31 mhvtl-0.18/usr/
[root@ www.linuxidc.com ~]# tar -tvvf /dev/st0
- drwxr-xr-x root/root 0 2012-08-16 16:29 mhvtl-0.18/
- drwxr-xr-x 1000/1000 0 2010-06-22 15:40 mhvtl-0.18/man/
- -rw-r--r-- 1000/1000 1309 2009-12-17 04:52 mhvtl-0.18/man/mhvtl.conf.5
- -rw-r--r-- 1000/1000 1081 2009-12-17 04:52 mhvtl-0.18/man/build_library_config.1
- -rw-r--r-- 1000/1000 2303 2009-12-17 04:52 mhvtl-0.18/man/vtlcmd.1
- -rw-r--r-- 1000/1000 3328 2009-12-17 04:52 mhvtl-0.18/man/mhvtl.1
- -rw-r--r-- 1000/1000 1371 2009-12-17 04:52 mhvtl-0.18/man/mktape.1
- -rw-r--r-- 1000/1000 888 2009-12-17 04:52 mhvtl-0.18/man/make_vtl_devices.1
- -rw-r--r-- 1000/1000 1599 2009-12-17 04:52 mhvtl-0.18/man/vtllibrary.1
测试倒带:
mt -f /dev/st0 rewind
卸载磁带:
[root@ www.linuxidc.com ~]# mtx -f /dev/sg10 unload 1 0
- Unloading drive 0 into Storage Element 1...done
- [root@ www.linuxidc.com ~]# mtx -f /dev/sg10 status
- Storage Changer /dev/sg10:4 Drives, 43 Slots ( 4 Import/Export )
- Data Transfer Element 0:Empty
- Data Transfer Element 1:Empty
- Data Transfer Element 2:Empty
- Data Transfer Element 3:Empty
注:nst0代表不回卷设备
先往磁带中写数据,然后在查看磁头位置
[root@ www.linuxidc.com ~]# tar -cvvf /dev/nst0 mhvtl-0.18/
[root@ www.linuxidc.com ~]# mt -f /dev/nst0 tell
At block 348.
倒带至磁带头并查看磁带内容,查看完内容后,会把磁带指针停止在内容位置后
mt -f /dev/nst0 rewind
[root@ www.linuxidc.com ~]# mt -f /dev/nst0 tell
At block 0.
继续添加文件至磁带机
[root@ www.linuxidc.com ~]# tar -cvvf /dev/nst0 mhvtl-0.18/
[root@ www.linuxidc.com ~]# mt -f /dev/nst0 tell
At block 348.
[root@ www.linuxidc.com ~]# tar -cvvf /dev/nst0 mhvtl-0.18/
[root@ www.linuxidc.com ~]# mt -f /dev/nst0 tell
At block 696.
对于nst磁带需要先倒带才能使用:
[root@ www.linuxidc.com ~]# mt -f /dev/nst0 rewind
[root@ www.linuxidc.com ~]# tar -tvf /dev/nst0
否则:
[root@ www.linuxidc.com ~]# tar -tvf /dev/nst0
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
清除磁带机中的数据并倒带至磁带头
[root@ www.linuxidc.com ~]# mt -f /dev/nst0 erase
[root@ www.linuxidc.com ~]# mt -f /dev/nst0 tel
At block 0.
一些命令帮助:
/dev/st0 回卷设备名
/dev/nst0 不回卷设备名
mt -f /dev/st0 tel 查看当前位置后回卷
mt -f /dev/nst0 tel 查看当前位置后不回卷
mt -f /dev/nst0 status 查看当前状态后不回卷
mt -f /dev/nst0 asf 1 前往block 1处后不回卷【一般不用】
tar tvf /dev/nst0 查看目录树后不回卷
tar tvf /dev/st0 查看目录树后回卷至0
mt -f /dev/nst0 rewind rewind 它可以使磁带快倒至磁带头
mt -f /dev/nst0 eod eod 定位磁带到最后可进行追加写入
mt -f /dev/nst0 fsf [欲前进的记录段数] fsf 它可以使磁带快速前进若干段记录[默认一段]
mt -f /dev/nst0 bsf [欲退回的记录段数] bsf 它可以使磁带快速后退若干段记录[默认一段]
mt -f /dev/nst0 offline offline 使磁带快倒至磁带头并弹出磁带机
mt -f /dev/st0 erase 清除数据后倒至磁带头【危险操作、时间较长】
mt -f /dev/st0 retension 拉紧磁带
