{"id":208,"date":"2011-07-17T10:39:02","date_gmt":"2011-07-16T22:39:02","guid":{"rendered":"http:\/\/mdickinson.dnsalias.org\/php\/wordpress\/?p=208"},"modified":"2011-08-04T17:35:04","modified_gmt":"2011-08-04T05:35:04","slug":"mhvtl-virtual-tape-software-take-2","status":"publish","type":"post","link":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/?p=208","title":{"rendered":"MHVTL Virtual tape software, take 2"},"content":{"rendered":"<p>I wanted to see if I could get iSCSI tape workingi <b>on fedora<\/b>, 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.<\/p>\n<p>Documented again as MHVTL installs much more cleanly in the latest version and works just perfectly; and I discovered <b>mtx<\/b> to manage the tape changer locally which is much easier.<\/p>\n<p>As MHVTL is now on <b>github<\/b> installation is much easier if you have git already installed (if you don&#8217;t yet &#8220;yum install git git-core&#8221;).<\/p>\n<h2>On my iSCSI target, easy installation<\/h2>\n<p><b>Note: you cannot use \/sbin\/nologin for the vtl user, it must have a valid shell to work<\/b><\/p>\n<pre>\r\ncd ~mark\r\nmkdir -p git\/mhvtl\r\ncd git\/mhvtl\r\ngit init\r\ngit pull http:\/\/github.com\/markh794\/mhvtl.git\r\ncd kernel\r\nmake\r\ncd ..\r\nmake\r\nsu - \r\ngroupadd -g 900 vtl\r\nuseradd -c \"mvhtl user\" -d \/home\/vtl -g vtl -m -s \/bin\/bash -u 900 vtl\r\ncd ~mark\/git\/mhvtl\r\ncd kernel\r\nmake install\r\ncd ..\r\nmake install\r\n<\/pre>\n<p>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.<\/p>\n<pre>\r\n[root@falcon mhvtl]# service mhvtl status\r\n\r\nCould not locate library config file: \/etc\/mhvtl\/library_contents.10\r\nCreating a default one\r\nPlease stop mhvtl & edit \/etc\/mhvtl\/library_contents.10 to suit your requirements\r\n\r\nCould not locate library config file: \/etc\/mhvtl\/library_contents.30\r\nCreating a default one\r\nPlease stop mhvtl & edit \/etc\/mhvtl\/library_contents.30 to suit your requirements\r\nUsage: \/etc\/init.d\/mhvtl {start|stop|shutdown}\r\n[root@falcon mhvtl]# \r\n[root@falcon etc]# cd \/etc\/mhvtl\r\n[root@falcon mhvtl]# ls\r\ndevice.conf  library_contents.10  library_contents.30  mhvtl.conf\r\n<\/pre>\n<p>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)<\/p>\n<p>If you don&#8217;t have &#8220;lsscsi&#8221; installed you should install that as a matter of course, I don&#8217;t know why it&#8217;s not standard. For the tape changers MHVTL is going to provide you with you also need to install &#8220;mtx&#8221; if you want to issue commands to them as I found vtlcmd either didn&#8217;t work (or just didn&#8217;t make sense to me). So &#8220;yum install lsscsi mtx&#8221; now to save time later.<\/p>\n<p>Before starting mhvtl <\/p>\n<pre>\r\n# lsscsi -g\r\n[root@falcon mhvtl]# lsscsi -g\r\n[0:0:0:0]    disk    ATA      WDC WD1600AAJB-0 00.0  \/dev\/sda   \/dev\/sg0\r\n[1:0:0:0]    cd\/dvd  SAMSUNG  CD-ROM SC-152L   C100  \/dev\/sr0   \/dev\/sg1\r\n[1:0:1:0]    cd\/dvd  CyberDrv CW068D CD-R\/RW   120D  \/dev\/sr1   \/dev\/sg2\r\n[2:0:0:0]    disk    Maxtor   Basics Desktop   0122  \/dev\/sdb   \/dev\/sg3\r\n[root@falcon mhvtl]#\r\n<\/pre>\n<p>Then start the mhvtl service and see what we have<\/p>\n<pre>\r\n[root@falcon mhvtl]# service mhvtl start\r\nvtllibrary process PID is 21111\r\nvtllibrary process PID is 21115\r\n[root@falcon mhvtl]# lsscsi -g\r\n[0:0:0:0]    disk    ATA      WDC WD1600AAJB-0 00.0  \/dev\/sda   \/dev\/sg0\r\n[1:0:0:0]    cd\/dvd  SAMSUNG  CD-ROM SC-152L   C100  \/dev\/sr0   \/dev\/sg1\r\n[1:0:1:0]    cd\/dvd  CyberDrv CW068D CD-R\/RW   120D  \/dev\/sr1   \/dev\/sg2\r\n[2:0:0:0]    disk    Maxtor   Basics Desktop   0122  \/dev\/sdb   \/dev\/sg3\r\n[3:0:0:0]    mediumx STK      L700             550V  \/dev\/sch0  \/dev\/sg12\r\n[3:0:1:0]    tape    IBM      ULT3580-TD5      550V  \/dev\/st0   \/dev\/sg4\r\n[3:0:2:0]    tape    IBM      ULT3580-TD5      550V  \/dev\/st1   \/dev\/sg5\r\n[3:0:3:0]    tape    IBM      ULT3580-TD4      550V  \/dev\/st2   \/dev\/sg6\r\n[3:0:4:0]    tape    IBM      ULT3580-TD4      550V  \/dev\/st3   \/dev\/sg7\r\n[3:0:8:0]    mediumx SPECTRA  PYTHON           550V  \/dev\/sch1  \/dev\/sg13\r\n[3:0:9:0]    tape    IBM      ULT3580-TD4      550V  \/dev\/st4   \/dev\/sg8\r\n[3:0:10:0]   tape    IBM      ULT3580-TD4      550V  \/dev\/st5   \/dev\/sg9\r\n[3:0:11:0]   tape    IBM      ULT3580-TD4      550V  \/dev\/st6   \/dev\/sg10\r\n[3:0:12:0]   tape    IBM      ULT3580-TD4      550V  \/dev\/st7   \/dev\/sg11\r\n[root@falcon mhvtl]#\r\n<\/pre>\n<p>Wasn&#8217;t that simple.<\/p>\n<h2>The next step is using it of course<\/h2>\n<p>The hard way to manually mount tapes is by using the mhvtl supplied command <b>vtlcmd<\/b>. That is so incredibly hard to figure out I suggest skipping that all together and installing <b>mtx<\/b> with a simply &#8216;yum install mtx&#8217; command.<\/p>\n<p>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.<\/p>\n<p>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.<\/p>\n<pre>\r\n[root@falcon kernel]# <b>mtx -f \/dev\/sg12 status<\/b>\r\n  Storage Changer \/dev\/sg12:4 Drives, 43 Slots ( 4 Import\/Export )\r\nData Transfer Element 0:Empty\r\nData Transfer Element 1:Empty\r\nData Transfer Element 2:Empty\r\nData Transfer Element 3:Empty\r\n      Storage Element 1:Full :VolumeTag=E01001L4                            \r\n      Storage Element 2:Full :VolumeTag=E01002L4                            \r\n      Storage Element 3:Full :VolumeTag=E01003L4                            \r\n      Storage Element 4:Full :VolumeTag=E01004L4                            \r\n      Storage Element 5:Full :VolumeTag=E01005L4                            \r\n      Storage Element 6:Full :VolumeTag=E01006L4                            \r\n      Storage Element 7:Full :VolumeTag=E01007L4                            \r\n      Storage Element 8:Full :VolumeTag=E01008L4                            \r\n      Storage Element 9:Full :VolumeTag=E01009L4                            \r\n      Storage Element 10:Full :VolumeTag=E01010L4                            \r\n      Storage Element 11:Full :VolumeTag=E01011L4                            \r\n      Storage Element 12:Full :VolumeTag=E01012L4                            \r\n      Storage Element 13:Full :VolumeTag=E01013L4                            \r\n      Storage Element 14:Full :VolumeTag=E01014L4                            \r\n      Storage Element 15:Full :VolumeTag=E01015L4                            \r\n      Storage Element 16:Full :VolumeTag=E01016L4\r\n      Storage Element 17:Full :VolumeTag=E01017L4                            \r\n      Storage Element 18:Full :VolumeTag=E01018L4                            \r\n      Storage Element 19:Full :VolumeTag=E01019L4                            \r\n      Storage Element 20:Full :VolumeTag=E01020L4                            \r\n      Storage Element 21:Empty\r\n      Storage Element 22:Full :VolumeTag=CLN101L4                            \r\n      Storage Element 23:Full :VolumeTag=CLN102L5                            \r\n      Storage Element 24:Empty\r\n      Storage Element 25:Empty\r\n      Storage Element 26:Empty\r\n      Storage Element 27:Empty\r\n      Storage Element 28:Empty\r\n      Storage Element 29:Empty\r\n      Storage Element 30:Full :VolumeTag=F01030L5                            \r\n      Storage Element 31:Full :VolumeTag=F01031L5                            \r\n      Storage Element 32:Full :VolumeTag=F01032L5                            \r\n      Storage Element 33:Full :VolumeTag=F01033L5                            \r\n      Storage Element 34:Full :VolumeTag=F01034L5                            \r\n      Storage Element 35:Full :VolumeTag=F01035L5                            \r\n      Storage Element 36:Full :VolumeTag=F01036L5                            \r\n      Storage Element 37:Full :VolumeTag=F01037L5                            \r\n      Storage Element 38:Full :VolumeTag=F01038L5                            \r\n      Storage Element 39:Full :VolumeTag=F01039L5\r\n      Storage Element 40 IMPORT\/EXPORT:Empty\r\n      Storage Element 41 IMPORT\/EXPORT:Empty\r\n      Storage Element 42 IMPORT\/EXPORT:Empty\r\n      Storage Element 43 IMPORT\/EXPORT:Empty\r\n\r\n[root@falcon ~]# <b>mt -f \/dev\/st0 status<\/b>\r\nSCSI 2 tape drive:\r\nFile number=-1, block number=-1, partition=0.\r\nTape block size 0 bytes. Density code 0x0 (default).\r\nSoft error count since last status=0\r\nGeneral status bits on (50000):\r\n DR_OPEN IM_REP_EN\r\n\r\n[root@falcon kernel]# <b>mtx -f \/dev\/sg12 load 1 0<\/b>\r\nLoading media from Storage Element 1 into drive 0...done\r\n\r\n[root@falcon ~]# <b>mt -f \/dev\/st0 status<\/b>\r\nSCSI 2 tape drive:\r\nFile number=-1, block number=-1, partition=0.\r\nTape block size 0 bytes. Density code 0x46 (LTO-4).\r\nSoft error count since last status=0\r\nGeneral status bits on (1010000):\r\n <em>ONLINE IM_REP_EN<\/em>\r\n[root@falcon kernel]# <b>mtx -f \/dev\/sg12 status<\/b>\r\n  Storage Changer \/dev\/sg12:4 Drives, 43 Slots ( 4 Import\/Export )\r\n<em>Data Transfer Element 0:Full (Storage Element 1 Loaded):VolumeTag = E01001L4<\/em>\r\nData Transfer Element 1:Empty\r\nData Transfer Element 2:Empty\r\nData Transfer Element 3:Empty\r\n      Storage Element 1:Empty\r\n      Storage Element 2:Full :VolumeTag=E01002L4                            \r\n      Storage Element 3:Full :VolumeTag=E01003L4                            \r\n      Storage Element 4:Full :VolumeTag=E01004L4                            \r\n      Storage Element 5:Full :VolumeTag=E01005L4                            \r\n      Storage Element 6:Full :VolumeTag=E01006L4                            \r\n      Storage Element 7:Full :VolumeTag=E01007L4                            \r\n      Storage Element 8:Full :VolumeTag=E01008L4                            \r\n      Storage Element 9:Full :VolumeTag=E01009L4                            \r\n      Storage Element 10:Full :VolumeTag=E01010L4                            \r\n      Storage Element 11:Full :VolumeTag=E01011L4                            \r\n      Storage Element 12:Full :VolumeTag=E01012L4                            \r\n      Storage Element 13:Full :VolumeTag=E01013L4                            \r\n      Storage Element 14:Full :VolumeTag=E01014L4                            \r\n      Storage Element 15:Full :VolumeTag=E01015L4                            \r\n      Storage Element 16:Full :VolumeTag=E01016L4\r\n      Storage Element 17:Full :VolumeTag=E01017L4                            \r\n      Storage Element 18:Full :VolumeTag=E01018L4                            \r\n      Storage Element 19:Full :VolumeTag=E01019L4                            \r\n      Storage Element 20:Full :VolumeTag=E01020L4                            \r\n      Storage Element 21:Empty\r\n      Storage Element 22:Full :VolumeTag=CLN101L4                            \r\n      Storage Element 23:Full :VolumeTag=CLN102L5                            \r\n      Storage Element 24:Empty\r\n      Storage Element 25:Empty\r\n      Storage Element 26:Empty\r\n      Storage Element 27:Empty\r\n      Storage Element 28:Empty\r\n      Storage Element 29:Empty\r\n      Storage Element 30:Full :VolumeTag=F01030L5                            \r\n      Storage Element 31:Full :VolumeTag=F01031L5                            \r\n      Storage Element 32:Full :VolumeTag=F01032L5                            \r\n      Storage Element 33:Full :VolumeTag=F01033L5                            \r\n      Storage Element 34:Full :VolumeTag=F01034L5                            \r\n      Storage Element 35:Full :VolumeTag=F01035L5                            \r\n      Storage Element 36:Full :VolumeTag=F01036L5                            \r\n      Storage Element 37:Full :VolumeTag=F01037L5                            \r\n      Storage Element 38:Full :VolumeTag=F01038L5                            \r\n      Storage Element 39:Full :VolumeTag=F01039L5\r\n      Storage Element 40 IMPORT\/EXPORT:Empty\r\n      Storage Element 41 IMPORT\/EXPORT:Empty\r\n      Storage Element 42 IMPORT\/EXPORT:Empty\r\n      Storage Element 43 IMPORT\/EXPORT:Empty\r\n[root@falcon kernel]# \r\n<\/pre>\n<p>The <b>mtx<\/b> shows data transfer element 0 has a tape loaded available for use; I couldn&#8217;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.<\/p>\n<p>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.<\/p>\n<p>Unloading from the drive back to a library slot is also as easy.<\/p>\n<pre>\r\n[root@falcon kernel]# mtx -f \/dev\/sg12 load 1 0\r\n<\/pre>\n<h2>Additional Steps I had to do<\/h2>\n<p>This didn&#8217;t work. Possibly just SeLinux as noted below.<\/p>\n<pre>\r\n[root@falcon kernel]# tgtadm --lld iscsi --op new --mode target --tid 2 -T iqn.2010-01.us.nimsa:tgt:4:16:0:0:T\r\n[root@falcon kernel]# tgtadm --lld iscsi --op new --mode logicalunit --tid 2 --lun 1 --bstype=sg --device-type=pt -b \/dev\/sg13\r\n<b>tgtadm: invalid request<\/b>\r\n<\/pre>\n<p><b>However<\/b> 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.<\/p>\n<pre>\r\n# install STGT\r\nyum install -y scsi-target-utils\r\nmkdir -p \/usr\/src\/tgt\r\ncd \/usr\/src\/tgt\r\nwget http:\/\/stgt.sourceforge.net\/releases\/tgt-1.0.18.tar.gz\r\ntar zxvf tgt-1.0.18.tar.gz\r\ncd tgt-1.0.18\r\nmake clean\r\nmake\r\nmake install\r\nchkconfig tgtd on\r\nservice tgtd start\r\n<\/pre>\n<p>Then using exactly the same tgtadm commands as listed above that didn&#8217;t work origionally&#8230; same error; but after updating my Selinux rules it worked.<\/p>\n<p><b>Note<\/b> that It may have been SeLinux that caused the origional error above, it may actually work with the supplied RPM.<\/p>\n<p>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.<\/p>\n<pre>\r\nrequire {\r\n\ttype tgtd_t;\r\n\tclass capability { sys_rawio sys_admin };\r\n}\r\nallow tgtd_t self:capability { sys_rawio sys_admin };\r\ndev_manage_all_blk_files(tgtd_t)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/?p=208\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-208","post","type-post","status-publish","format-standard","hentry","category-my-nux-thoughts-and-notes"],"_links":{"self":[{"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=208"}],"version-history":[{"count":14,"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/208\/revisions"}],"predecessor-version":[{"id":216,"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/208\/revisions\/216"}],"wp:attachment":[{"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mdickinson.dyndns.org\/php\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}