Pages

Saturday, January 21, 2012

mhvtl - Virtual Tape Library

A few days ago I discovered a pretty cool software for creating a virtual tape library. You can use the virtual tape library as a real library with the robot, drives, tapes etc. Best of all: the tapes are flat files within their own directory. That means that you can setup a HP MSL6000 tape library with 4 drives and 52 tapes and keeping the tape size at 50MB. With this article I want you to show the following:

Install mhvtl from source
Configure a virtual HP MSL6000 tape library
Perform a simple backup
mhvtl Web Gui

mhvtl is a real Linux software and I am running Slackware again. But it shouldn't be to hard to install mhvtl under any other Linux distribution.

Install mhvtl from source

To install mhvtl get the source first:

# cd /usr/src
# wget "https://sites.google.com/site/linuxvtl2/mhvtl-2013-01-31.tgz?attredirects=0" -O mhvtl-2013-01-31.tgz
...


Before you start compiling add a group and a user (make sure the gid and uid are unused):

# groupadd -g 95 vtl
# useradd -c "Vitrual Tape Library" -d /opt/mhvtl -g vtl -m vtl -s /bin/bash -u 95


Then extract the source package and change into the new directory:

# tar xf mhvtl-2013-01-31.tgz
# cd mhvtl-1.4


Just type make followed by make install to compile and install the daemons:

# make
...
# make install
...


Then change into the kernel directory and build the kernel module:

# cd /usr/src/mhvtl-1.4/kernel
# make
...
# make install
...


Copy the the init script and make it executable:

# cp /usr/src/mhvtl-1.4/etc/mhvtl /etc/rc.d/rc.mhvtl
# chmod 755 /etc/rc.d/rc.mhvtl


Don't start mhvtl now, read the next section first.

Configure a virtual HP MSL6000 tape library

Before you start mhvtl you have to configure it. All configuration files reside under /etc/mhvtl, so create the directory first:

# mkdir /etc/mhvtl

Then configure the main configuration file mhvtl.conf:

# vi /etc/mhvtl/mhvtl.conf
MHVTL_CONFIG_PATH=/etc/mhvtl
CAPACITY=50
VERBOSE=1
VTL_DEBUG=0


With the CAPACITY value above all virtual tapes will have a size of 50MB. If you need more or less capacity then increase or decrease the CAPACITY value above. Next configure the tape library itself. As mentioned in the beginning of this article I will setup a virtual HP MSL6000 with four tape drives and 48 tapes. The following device.conf file will configure one changer and four tape drives:

# vi /etc/mhvtl/device.conf
Library: 90 CHANNEL: 3 TARGET: 00 LUN: 00
 Vendor identification: HP
 Product identification: MSL6000 Series
 Product revision level: 2.00
 Unit serial number: 80000090
 NAA: 90:11:22:33:ab:3:00:00

 Home directory: /opt/mhvtl/90
 fifo: /var/tmp/mhvtl

Drive: 91 CHANNEL: 3 TARGET: 00 LUN: 01
 Library ID: 90 Slot: 01
 Vendor identification: HP
 Product identification: Ultrium 3-SCSI
 Product revision level: N11G
 Unit serial number: 80000091
 NAA: 90:11:22:33:ab:3:00:01
 Compression: factor 1 enabled 1
 fifo: /var/tmp/mhvtl

Drive: 92 CHANNEL: 3 TARGET: 00 LUN: 2
 Library ID: 90 Slot: 2
 Vendor identification: HP
 Product identification: Ultrium 3-SCSI
 Product revision level: N11G
 Unit serial number: 80000092
 NAA: 90:11:22:33:ab:3:00:2
 Compression: factor 1 enabled 1
 fifo: /var/tmp/mhvtl

Drive: 93 CHANNEL: 3 TARGET: 00 LUN: 3
 Library ID: 90 Slot: 3
 Vendor identification: HP
 Product identification: Ultrium 3-SCSI
 Product revision level: N11G
 Unit serial number: 80000093
 NAA: 90:11:22:33:ab:3:00:3
 Compression: factor 1 enabled 1
 fifo: /var/tmp/mhvtl

Drive: 94 CHANNEL: 3 TARGET: 00 LUN: 4
 Library ID: 90 Slot: 4
 Vendor identification: HP
 Product identification: Ultrium 3-SCSI
 Product revision level: N11G
 Unit serial number: 80000094
 NAA: 90:11:22:33:ab:3:00:4
 Compression: factor 1 enabled 1
 fifo: /var/tmp/mhvtl


At least configure the content configuration file which holds all tapes:

# vi /etc/mhvtl/library_contents.90
Drive1:
Drive2:
Drive3:
Drive4:

MAP 1:
MAP 2:
MAP 3:
MAP 4:

Picker 1:

Slot 1: HPS001L3
Slot 2: HPS002L3
Slot 3: HPS003L3
Slot 4: HPS004L3
Slot 5: HPS005L3
Slot 6: HPS006L3
Slot 7: HPS007L3
Slot 8: HPS008L3
Slot 9: HPS009L3
Slot 10: HPS010L3
Slot 11: HPS011L3
Slot 12: HPS012L3
Slot 13: HPS013L3
Slot 14: HPS014L3
Slot 15: HPS015L3
Slot 16: HPS016L3
Slot 17: HPS017L3
Slot 18: HPS018L3
Slot 19: HPS019L3
Slot 20: HPS020L3
Slot 21: HPS021L3
Slot 22: HPS022L3
Slot 23: HPS023L3
Slot 24: HPS024L3
Slot 25: HPS025L3
Slot 26: HPS026L3
Slot 27: HPS027L3
Slot 28: HPS028L3
Slot 29: HPS029L3
Slot 30: HPS030L3
Slot 31: HPS031L3
Slot 32: HPS032L3
Slot 33: HPS033L3
Slot 34: HPS034L3
Slot 35: HPS035L3
Slot 36: HPS036L3
Slot 37: HPS037L3
Slot 38: HPS038L3
Slot 39: HPS039L3
Slot 40: HPS040L3
Slot 41: HPS041L3
Slot 42: HPS042L3
Slot 43: HPS043L3
Slot 44: HPS044L3
Slot 45: HPS045L3
Slot 46: HPS046L3
Slot 47: HPS047L3
Slot 48: CLN048L3


When everything is configured then change the permissions for the configuration files to the prior created vtl user:

# chown -R vtl:vtl /etc/mhvtl/

Now give it a try and start mhvtl. The first start may take a while because all tapes will be created first:

# /etc/rc.d/rc.mhvtl start
vtllibrary process PID is 17167


Next check if the virtual MSL6000 was created:

# lsscsi -g
...
[10:3:0:0]   mediumx HP       MSL6000 Series   2.00  /dev/sch0  /dev/sg8
[10:3:0:1]   tape    HP       Ultrium 3-SCSI   N11G  /dev/st0   /dev/sg4
[10:3:0:2]   tape    HP       Ultrium 3-SCSI   N11G  /dev/st1   /dev/sg5
[10:3:0:3]   tape    HP       Ultrium 3-SCSI   N11G  /dev/st2   /dev/sg6
[10:3:0:4]   tape    HP       Ultrium 3-SCSI   N11G  /dev/st3   /dev/sg7


Perform a simple backup

When the virtual tape library is up then you are ready for a simple backup. First load the first tape into the first drive:

# mtx -f /dev/sg8 load 1 0
Loading media from Storage Element 1 into drive 0...done


Now check that the tape was loaded:

# mtx -f /dev/sg8 status
  Storage Changer /dev/sg8:4 Drives, 52 Slots ( 4 Import/Export )
Data Transfer Element 0:Full (Storage Element 1 Loaded):VolumeTag = HPS001L3                         
Data Transfer Element 1:Empty
Data Transfer Element 2:Empty
Data Transfer Element 3:Empty
      Storage Element 1:Empty
      Storage Element 2:Full :VolumeTag=HPS002L3
...


Then use tar to store the /etc directory on the tape:

# tar cf /dev/st0 /etc/

Unload the tape from drive 0 to storage again:

# mtx -f /dev/sg8 unload 1 0
Unloading drive 0 into Storage Element 1...done


And check that the tape was unloaded:

# mtx -f /dev/sg7 status | head -10
  Storage Changer /dev/sg7:4 Drives, 52 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=HPS001L3
      Storage Element 2:Full :VolumeTag=HPS002L3
...


All tapes are in the home directory of the vtl user which was set to /opt/mhvtl. The more you use the tape library the bigger the files are becoming:

# du -hs /opt/mhvtl/90/*
8.0K    /opt/mhvtl/CLN048L3
3.4M    /opt/mhvtl/HPS001L3
8.0K    /opt/mhvtl/HPS002L3
...


The first directory is the cleaning tape, the second directory contains the backup of /etc and all other tapes are unused.

mhvtl Web Gui

The Web Gui is very handy to create another tape library, remove a tape library etc. The configuration above for the HP MSL6000 was create with it. First get the package for the mhvtl web gui:

# cd /usr/src
# wget --no-check-certificate "https://github.com/niadev67/mhvtl-gui/tarball/master/" -O mhvtl-gui.tar.gz
...


Then extract it:

# tar xfz mhvtl-gui.tar.gz

And move the content to the htdocs directory of your webserver:

# mkdir -p /srv/www/htdocs/mhvtl
# mv niadev*/* /srv/www/htdocs/mhvtl


Next you have to find out which user runs the httpd daemon (mostly apache) and allow it to use sudo:

# ps -ef | grep http
apache     815  1945  0  2011 ?        00:00:14 /usr/sbin/httpd -k start
...


Add the apache user to sudoers:

# echo "apache ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

Now navigate your browser to the appropiate url (eg. http://192.168.1.73/mhvtl-gui/). You can login with the password 'mhvtl' (the password can be change in the go.php file).

As I told you mhvtl is a real nice software to setup a virtual tape library eg. for testing purpose or practicing.

Update 2013-07-03: Updated to the current mhvtl version 1.4 and tested on Slackware 14.0


6 comments:

  1. I am new to mhvtl. I follow your steps. But failed when compiling mhvtl code.any help will be appreciated.
    Thank's & Regard's
    Skycaddie sg4

    ReplyDelete
    Replies
    1. I can't help without an error message. Please post the complete error message not just the last line(s).

      Delete
  2. Hi Karellen,
    Iam configuring mhvtl on RHEL with TivoliStorageManagement software for backup , but Iam confusing with TARGET and LUN in device.conf , am using 4 libraries each library have 4 drives and approximately 20 tapes , everything went perfectly and I successfully created libraries and tapes on Linux box itself located in /opt/mhvtl . I put TARGET=00 and LUN=00 .....09,10,11 ,
    My question is how to configure TARGET and LUN in device.conf for all the four libraries and drives in the libraries
    Iam new to mhvtl , Please help me
    Regards,
    Syam.

    ReplyDelete
    Replies
    1. Hi Syam, your question is not really about mhvtl ;-)
      Let me try to explain that: imagine you have a SCSI controller with 3 connectors - 2 internal and 1 external (eg. take a look at a Adaptec 29160). Then the SCSI controller is channel 0 (if it is the only SCSI adapter in your server), the first connector (eg. the external) is target 0 and the first device on this connector is lun 0. If you connect a device to the first internal connector of the SCSI adapter then the SCSI adapter is still channel 0, the target will be 1 and the device will be lun 0 again, the second device will be lun 1 and so on.
      In my example I set the channel to three, when I wrote this article I had a few SCSI adapters connected to my machine: one on-board SATA adapter (channel 0), one extra PCI SATA adapter (channel 1) and an old SCSI adapter (channel 2) for my old stuff. The next free channel would be three, the first target (or connector) zero and all devices on that target are numbered.
      If you should ever face Solaris, HP-UX or else then you will notice that the harddisk devices in the OS follow the same scheme (c0t0d0, c1t0d0 etc.).
      Hope I could clear up a few things?

      Delete
    2. Not to take away from Kar's excellent blog, but I would advise to ask trouble-shooting type questions on the 'mhvtl forum' at : http://mhvtl-linux-virtual-tape-library-community-forums.966029.n3.nabble.com/

      Delete
  3. Hi Karellen ,
    Thank u very much for u'r response to me in your busy life , now I got good idea about LUNs and TARGETs .Hope u'r explanation may help to some others who doesn't have enough idea on these things.
    Thanks&Regards,
    Syam.

    ReplyDelete