I've been using/managing tape library for many years, still remember I spent 3 days searching for a nonpropretary virtual tape library for my tape application development. I couldn't find one at that time, so I made pretty one just for my development. Now, I don't have to fight with test library anymore, but this one still caught my eyes, couldn't help not to try it. Great!

mhvtl is a linux virtual tape library program, its kernel module is based on scsi_debug kernel module, mhvtl.ko is a pseudo HBA (LLD).

Its target devices are vtltape and vtllibrary.

Utilite commands mktape, vtlcmd

And startup scripts build_library_config(1), make_vtl_devices(1)


As of version 1.4-9, mhvtl can emulate most popular tape libraries.

List of Emulations

Working emulations

    IBM LTO (1/2/3/4 & 5) (LTO 5 emulation does not support LTFS)
    HP LTO (1/2/3/4 & 5) (LTO 5 emulation does not support LTFS)
    IBM 03592-J1A, 03592-E05 & 03592-E06
    STK 9840 (A/B/C/D), 9940 (A/B)
    STK T10000 (A/B/C)
    Sony AIT (1/2/3 &4)

What about model X....

    Quantum (DLT/Super-DLT) is NOT supported as their SCSI Programmer's Guide does not document the expected returned data.
    DDS (4mm DAT) - I've not found any SCSI programmers' Guides for these drives.

Library emulation is coming in the future.

STK L180/L700 emulation works for NetBackup & NetWorker.
TSM - IBM library type needed to use LTO drives.

Note: Currently, only the tape module has 'personality modules'


Two packages are needed and they are in ELREPO on RHEL6/SL6 and CentOS. Though they are one version behind git, they stil look good.

#rpm --list *mhvtl*
kmod-mhvtl.x86_64              1.3-1.el6.elrepo                        @elrepo
mhvtl-utils.x86_64             1.3-1.el6.elrepo                        @elrepo

lzo will be installed as indenpents

Config and run

It's simple, just run the command below.

/etc/init.d/mhvtl start

By default, the default tape file location is /opt/mhvtl, so if you want to use different filesystem/directory for virtual tapes, make a symbol link(no option to change so far, hope in future release, the location can be change in configuration)

ln -s /opt/mhvtl <your virtual location>

As for library, there are two libraries configured, they are in /etc/mhvtl. I changed one to IBM TS3500, I put /etc/mhvtl/device.conf origional and new output here, you can see not much need to be changed.

<  Vendor identification: IBM
<  Product identification: 03584L32
origional one
>  Vendor identification: STK
>  Product identification: L700

Configuration change needs a restart to take effect, so after restart, it looks like this.

Show scsi devices

#lsscsi -g
[1:0:0:0]    cd/dvd  NECVMWar VMware IDE CDR10 1.00  /dev/sr0   /dev/sg0
[2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda   /dev/sg1
[3:0:0:0]    mediumx IBM      03584L32         0103  /dev/sch0  /dev/sg10
[3:0:1:0]    tape    IBM      ULT3580-TD5      0103  /dev/st0   /dev/sg2
[3:0:2:0]    tape    IBM      ULT3580-TD5      0103  /dev/st1   /dev/sg3
[3:0:3:0]    tape    IBM      ULT3580-TD4      0103  /dev/st2   /dev/sg4
[3:0:4:0]    tape    IBM      ULT3580-TD4      0103  /dev/st3   /dev/sg5
[3:0:8:0]    mediumx STK      L80              0103  /dev/sch1  /dev/sg11
[3:0:9:0]    tape    STK      T10000B          0103  /dev/st4   /dev/sg6
[3:0:10:0]   tape    STK      T10000B          0103  /dev/st5   /dev/sg7
[3:0:11:0]   tape    STK      T10000B          0103  /dev/st6   /dev/sg8
[3:0:12:0]   tape    STK      T10000B          0103  /dev/st7   /dev/sg9

Check scsi VPD

#scsi_id --page 0x80 --whitelist --device=/dev/sg10
SIBM     03584L32       XYZZY_A
#scsi_id --page 0x80 --whitelist --device=/dev/sg11
SSTK     L80            XYZZY_B
#scsi_id --page 0x80 --whitelist --device=/dev/st0
SIBM     ULT3580-TD5    XYZZY_A1
#scsi_id --page 0x83 --whitelist --device=/dev/st0

Check device tree

It's from a pseudo adapter, so you can't get it from lspci

#udevadm info -a --path=/class/scsi_tape/st0 | grep "looking at device"
  looking at device '/devices/pseudo_0/adapter0/host3/target3:0:1/3:0:1:0/scsi_tape/st0':
#udevadm info -a --path=/class/scsi_changer/sch0 | grep "looking at device"
  looking at device '/devices/pseudo_0/adapter0/host3/target3:0:0/3:0:0:0/scsi_changer/sch0':


I also tried to use stinit to initialized scsi2_logic for LTO tape drives, they are all succeed, support global blocking.

#mt -f /dev/fctd51 seek 0
#tar tvf /dev/fctd51
-rw-r--r-- vtl/vtl        3136 2013-08-30 06:24 ./device.conf
-rw-r--r-- vtl/vtl        3132 2013-08-30 06:23 ./device.conf.orig
-rw-r--r-- vtl/vtl        1373 2013-08-30 01:48 ./library_contents.10
-rw-r--r-- vtl/vtl        1453 2013-08-30 01:48 ./library_contents.30
-rw-r--r-- vtl/vtl         206 2013-08-30 01:48 ./mhvtl.conf
#mt -f /dev/fctd51 tell
At block 2.


Media changer works beautifully too

Check library status

#mtx -f /dev/sg10 status
  Storage Changer /dev/sg10:4 Drives, 43 Slots ( 4 Import/Export )
Data Transfer Element 0:Full (Storage Element 30 Loaded):VolumeTag = F01030L5
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

Unload tape catridge

#mtx -f /dev/sg10 unload 30 0
Unloading drive 0 into Storage Element 30...done

It doesn't emulate time cost which mechnical movement would have, so when you use it for development, count this factor in, other than that, nothing to complain.

Check out more details in https://sites.google.com/site/linuxvtl2


Note: By default, this virtual tape library generates numerous lines of logs to syslog, even its kernel debug is turned off, I did some effort to discard/separate message mhvtl created, see How to filter mhvtl generated syslog message

Comments powered by CComment