MHVTL Virtual tape software, take 2

I wanted to see if I could get iSCSI tape workingi on fedora, it had been a while since I last tried and I thought maybe tape support had been introduced to Fedora by now. It is, although I had to compile from source.

Documented again as MHVTL installs much more cleanly in the latest version and works just perfectly; and I discovered mtx to manage the tape changer locally which is much easier.

As MHVTL is now on github installation is much easier if you have git already installed (if you don’t yet “yum install git git-core”).

On my iSCSI target, easy installation

Note: you cannot use /sbin/nologin for the vtl user, it must have a valid shell to work

cd ~mark
mkdir -p git/mhvtl
cd git/mhvtl
git init
git pull http://github.com/markh794/mhvtl.git
cd kernel
make
cd ..
make
su - 
groupadd -g 900 vtl
useradd -c "mvhtl user" -d /home/vtl -g vtl -m -s /bin/bash -u 900 vtl
cd ~mark/git/mhvtl
cd kernel
make install
cd ..
make install

Running the service the first time (I just used status which was invalid, thats fine) creates default configuration files that define two tape changer devices with tape drives and a bunch of precreated tapes in the libraries.

[root@falcon mhvtl]# service mhvtl status

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
Usage: /etc/init.d/mhvtl {start|stop|shutdown}
[root@falcon mhvtl]# 
[root@falcon etc]# cd /etc/mhvtl
[root@falcon mhvtl]# ls
device.conf  library_contents.10  library_contents.30  mhvtl.conf

What the defaults are, as of July 2011 anyway, are device.conf defines two libraries, 10 (drive 11-14) and 30 (drive 32-34), library 10 has LTO4(E01001-E01020, slot 1-20)+LTO5(F01030-F01039, slot 30-39)+2 cleaning tapes (slot 22-23), library 30 has LTO4(E03001-E03020, slot 1-20)+LTO5(F03030-F03039, slot 30-39)+2 cleaning tapes (slot 22-23)

If you don’t have “lsscsi” installed you should install that as a matter of course, I don’t know why it’s not standard. For the tape changers MHVTL is going to provide you with you also need to install “mtx” if you want to issue commands to them as I found vtlcmd either didn’t work (or just didn’t make sense to me). So “yum install lsscsi mtx” now to save time later.

Before starting mhvtl

# lsscsi -g
[root@falcon mhvtl]# lsscsi -g
[0:0:0:0]    disk    ATA      WDC WD1600AAJB-0 00.0  /dev/sda   /dev/sg0
[1:0:0:0]    cd/dvd  SAMSUNG  CD-ROM SC-152L   C100  /dev/sr0   /dev/sg1
[1:0:1:0]    cd/dvd  CyberDrv CW068D CD-R/RW   120D  /dev/sr1   /dev/sg2
[2:0:0:0]    disk    Maxtor   Basics Desktop   0122  /dev/sdb   /dev/sg3
[root@falcon mhvtl]#

Then start the mhvtl service and see what we have

[root@falcon mhvtl]# service mhvtl start
vtllibrary process PID is 21111
vtllibrary process PID is 21115
[root@falcon mhvtl]# lsscsi -g
[0:0:0:0]    disk    ATA      WDC WD1600AAJB-0 00.0  /dev/sda   /dev/sg0
[1:0:0:0]    cd/dvd  SAMSUNG  CD-ROM SC-152L   C100  /dev/sr0   /dev/sg1
[1:0:1:0]    cd/dvd  CyberDrv CW068D CD-R/RW   120D  /dev/sr1   /dev/sg2
[2:0:0:0]    disk    Maxtor   Basics Desktop   0122  /dev/sdb   /dev/sg3
[3:0:0:0]    mediumx STK      L700             550V  /dev/sch0  /dev/sg12
[3:0:1:0]    tape    IBM      ULT3580-TD5      550V  /dev/st0   /dev/sg4
[3:0:2:0]    tape    IBM      ULT3580-TD5      550V  /dev/st1   /dev/sg5
[3:0:3:0]    tape    IBM      ULT3580-TD4      550V  /dev/st2   /dev/sg6
[3:0:4:0]    tape    IBM      ULT3580-TD4      550V  /dev/st3   /dev/sg7
[3:0:8:0]    mediumx SPECTRA  PYTHON           550V  /dev/sch1  /dev/sg13
[3:0:9:0]    tape    IBM      ULT3580-TD4      550V  /dev/st4   /dev/sg8
[3:0:10:0]   tape    IBM      ULT3580-TD4      550V  /dev/st5   /dev/sg9
[3:0:11:0]   tape    IBM      ULT3580-TD4      550V  /dev/st6   /dev/sg10
[3:0:12:0]   tape    IBM      ULT3580-TD4      550V  /dev/st7   /dev/sg11
[root@falcon mhvtl]#

Wasn’t that simple.

The next step is using it of course

The hard way to manually mount tapes is by using the mhvtl supplied command vtlcmd. That is so incredibly hard to figure out I suggest skipping that all together and installing mtx with a simply ‘yum install mtx’ command.

As using mtx is much simpler, and provides a lot more display output as to what is happening, all examples in here are using mtx.

The libraries installed became on my system (identified from the lsscsi command shown earlier) sg12 and sg13, these examples show how easy it is to use mtx to display the library and mount, use and unmount tapes in the autoloader using the tapes in the library.

[root@falcon kernel]# mtx -f /dev/sg12 status
  Storage Changer /dev/sg12: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

[root@falcon ~]# mt -f /dev/st0 status
SCSI 2 tape drive:
File number=-1, block number=-1, partition=0.
Tape block size 0 bytes. Density code 0x0 (default).
Soft error count since last status=0
General status bits on (50000):
 DR_OPEN IM_REP_EN

[root@falcon kernel]# mtx -f /dev/sg12 load 1 0
Loading media from Storage Element 1 into drive 0...done

[root@falcon ~]# mt -f /dev/st0 status
SCSI 2 tape drive:
File number=-1, block number=-1, partition=0.
Tape block size 0 bytes. Density code 0x46 (LTO-4).
Soft error count since last status=0
General status bits on (1010000):
 ONLINE IM_REP_EN
[root@falcon kernel]# mtx -f /dev/sg12 status
  Storage Changer /dev/sg12: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
      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
[root@falcon kernel]# 

The mtx shows data transfer element 0 has a tape loaded available for use; I couldn’t figure out how to do that with vtlcmd. And it is easier to match the lsscsi output with devices rather than poke through the MHVTL config files to see whats where.

I was able to match up the drives simply by knowing I had no tape devices installed so /dev/st0 through /dev/st7 were the MHVTL tape devices (four per library) and that /dev/st0 (and I am assuming the next three) were for the first changer simply by writing/reading from /dev/st0.

Unloading from the drive back to a library slot is also as easy.

[root@falcon kernel]# mtx -f /dev/sg12 load 1 0

Additional Steps I had to do

This didn’t work. Possibly just SeLinux as noted below.

[root@falcon kernel]# tgtadm --lld iscsi --op new --mode target --tid 2 -T iqn.2010-01.us.nimsa:tgt:4:16:0:0:T
[root@falcon kernel]# tgtadm --lld iscsi --op new --mode logicalunit --tid 2 --lun 1 --bstype=sg --device-type=pt -b /dev/sg13
tgtadm: invalid request

However One of the posts for configuring mhvtl on CentOS had a walk through for Centos that installed iscsi-target-utils (which in Fedora was 1.0.18 already, presumablt to get config files etc setup automatically) and then when that was installed manually pulled down and compiled stgt directly for the same 1.0.18 version to replace the fedora supplied one. So I tried that.

# install STGT
yum install -y scsi-target-utils
mkdir -p /usr/src/tgt
cd /usr/src/tgt
wget http://stgt.sourceforge.net/releases/tgt-1.0.18.tar.gz
tar zxvf tgt-1.0.18.tar.gz
cd tgt-1.0.18
make clean
make
make install
chkconfig tgtd on
service tgtd start

Then using exactly the same tgtadm commands as listed above that didn’t work origionally… same error; but after updating my Selinux rules it worked.

Note that It may have been SeLinux that caused the origional error above, it may actually work with the supplied RPM.

The additional selinux rules I had to add to my custom config to allow mhvtl virtual tape devices to be used were as below; it may not be all required as I have so many customised rules some other required rules may already exist in my selinux configurations.

require {
	type tgtd_t;
	class capability { sys_rawio sys_admin };
}
allow tgtd_t self:capability { sys_rawio sys_admin };
dev_manage_all_blk_files(tgtd_t)

About mark

At work, been working on Tandems for around 30yrs (programming + sysadmin), plus AIX and Solaris sysadmin also thrown in during the last 20yrs; also about 5yrs on MVS (mainly operations and automation but also smp/e work). At home I have been using linux for decades. Programming background is commercially in TAL/COBOL/SCOBOL/C(Tandem); 370 assembler(MVS); C, perl and shell scripting in *nix; and Microsoft Macro Assembler(windows).
This entry was posted in Unix. Bookmark the permalink.