1、安装一些系统包,这一步需要确定你有可用的yum源,要不然只能去光盘中一个一个找了。
yum install gcc mtx mt-st zlib-devel sg3_utils kernel-devel lsscsi kernel-headers kernel -y
2、创建用户,并设置密码
useradd vtl
echo ‘vtl’ |passwd –stdin vtl
3、创建虚拟带库存储路径和配置文件路径
mkdir /opt/mhvtl
mkdir /etc/mhvtl
修改目录属性
chown -Rf vtl:vtl mkdir /opt/mhvtl
chown -Rf vtl:vtl mkdir /etc/mhvtl
4、去下面的网站中下载一个最新的mhvtl源码,这个地址可能需要墙了才能打开,如果不最求最新版本则可以随便百度一个并下载下来用即可。
https://sites.google.com/site/linuxvtl2/
把文件上传至服务并解压
tar xvfz mhvtl-2012-08-08.tgz
5、安装编译
cd mhvtl-1.4/
make distclean
cd kernel/
make
make install
cd ../
make
make install
6、启动mhvtl服务进程
/etc/init.d/mhvtl start
7、查看带库相关信息
ls /etc/mhvtl/
ls /opt/mhvtl/
[root@ www.linuxidc.com ~]# lsscsi -g
- [1:0:0:0] cd/dvd NECVMWar VMware IDE CDR10 1.00 /dev/sr0 /dev/sg0
- [2:0:0:0] disk VMware Virtual disk 1.0 /dev/sda /dev/sg1
- [3:0:0:0] mediumx STK L700 550V /dev/sch0 /dev/sg10
- [3:0:1:0] tape IBM ULT3580-TD5 550V /dev/st0 /dev/sg2
- [3:0:2:0] tape IBM ULT3580-TD5 550V /dev/st1 /dev/sg3
- [3:0:3:0] tape IBM ULT3580-TD4 550V /dev/st2 /dev/sg4
- [3:0:4:0] tape IBM ULT3580-TD4 550V /dev/st3 /dev/sg5
- [3:0:8:0] mediumx SPECTRA PYTHON 550V /dev/sch1 /dev/sg11
- [3:0:9:0] tape IBM ULT3580-TD4 550V /dev/st4 /dev/sg6
- [3:0:10:0] tape IBM ULT3580-TD4 550V /dev/st6 /dev/sg8
- [3:0:11:0] tape IBM ULT3580-TD4 550V /dev/st5 /dev/sg7
- [3:0:12:0] tape IBM ULT3580-TD4 550V /dev/st7 /dev/sg9
lsscsi -l
注:设备类型为mediumx的设备/dev/sg10和/dev/sg11是机械手。
磁带默认的容量是500MB,这个可以查看mhvtl的配置文件mhvtl.conf:
[root@utf10g ~]# cat /etc/mhvtl/mhvtl.conf
- # Home directory for config file(s)
- MHVTL_CONFIG_PATH=/etc/mhvtl
- # Default media capacity (500 M)
- CAPACITY=500
- # Set default verbosity [0|1|2|3]
- VERBOSE=1
- # Set kernel module debuging [0|1]
- VTL_DEBUG=0
capacity=500就是指默认容量为500MB。
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 拉紧磁带