Linux安裝虚拟磁带机

17 篇文章 0 订阅
9 篇文章 0 订阅
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服务进程

[root@zhs11g ~]# /etc/init.d/mhvtl start

Could not locate library config file: /etc/mhvtl/library_contents.10
Creating a default one
Please stop mhvtl & edit /etc/mhvtl/library_contents.10 to suit your requirements

Could not locate library config file: /etc/mhvtl/library_contents.30
Creating a default one
Please stop mhvtl & edit /etc/mhvtl/library_contents.30 to suit your requirements
vtltape: version 0.18.10
vtltape: version 0.18.10
vtltape: version 0.18.10
vtltape: version 0.18.10
vtltape: version 0.18.10
vtltape: version 0.18.10
vtltape: version 0.18.10
vtltape: version 0.18.10
vtllibrary: version 0.18.10
vtllibrary process PID is 20378
vtllibrary: version 0.18.10
vtllibrary process PID is 20422

7、查看带库相关信息
ls /etc/mhvtl/ 
ls /opt/mhvtl/ 
[root@mhvtl ~]# 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@mhvtl ~]# 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
      

以上信息的意思是:该机械手有4个驱动(磁头:Data Transfer Element),43个槽位(磁带:Storage Element),其中Empty到槽位表示是没有磁带的,另外4个槽位是用于导入导出的。

将磁带从1号槽位(1号磁带)装入driver 0(0号磁头):

[root@mhvtl ~]# mtx -f /dev/sg10 load 1 0
Loading media from Storage Element 1 into drive 0...done
[root@mhvtl ~]# 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@mhvtl ~]# 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
 
使用tar命令测试磁带写入,其实是通过0号磁头写入数据到1号磁带:
[root@mhvtl ~]# 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/

使用tar命令测试磁带读取:
[root@mhvtl ~]# 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@mhvtl ~]# mtx -f /dev/sg10 unload 1 0
Unloading drive 0 into Storage Element 1...done
[root@mhvtl ~]# 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

注:nst[N]代表不回卷设备,和st[N]设备其实是统一个磁头,只是nst设备在写入数据到磁带后不会把磁带倒到开始位置,而st设备会。
先往磁带中写数据,然后再查看磁头位置
[root@mhvtl ~]# tar -cvvf /dev/nst0 mhvtl-0.18/
[root@mhvtl ~]# mt -f /dev/nst0 tell
At block 348.


如果要查看之前写入磁带到数据,则需要把倒带至磁带头,查看完内容后,同样会把磁带指针停止在内容位置后
mt -f /dev/nst0 rewind
[root@mhvtl ~]# mt -f /dev/nst0 tell
At block 0.


只有nst设备才可以继续添加文件至磁带机,
[root@mhvtl ~]# tar -cvvf /dev/nst0 mhvtl-0.18/
[root@mhvtl ~]# mt -f /dev/nst0 tell
At block 348.
[root@mhvtl ~]# tar -cvvf /dev/nst0 mhvtl-0.18/
[root@mhvtl ~]# mt -f /dev/nst0 tell
At block 696.


对于nst磁带需要先倒带才能使用:
[root@mhvtl ~]# mt -f /dev/nst0 rewind
[root@mhvtl ~]# tar -tvf /dev/nst0
否则就会提示找不到文件,其实就是从磁带到最会一次访问位置开始往下访问肯定是没有文件到咯:
[root@mhvtl ~]# tar -tvf /dev/nst0
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors




清除磁带机中的数据并倒带至磁带头
[root@mhvtl ~]# mt -f /dev/nst0 erase
[root@mhvtl ~]# 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                            拉紧磁带












  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值