mhVTL on CentOS 6 / 7

By | 31 Jan 2015

I frequently use tape devices, libraries and drives, in my daily course of work.  Unfortunately it isn’t possible to have every type of device in a lab or in many cases any physical devices available for testing, etc. When it comes to VTLs (Virtual Tape Libraries) there are a handful of vendors and options ranging from thousands of dollars to free.  Luckily I work with the developer of what may be the most popular open-source VTL available, mhVTL, which is very scalable.

More information about the mhVTL can be found here:

For this example I am using a CentOS 7 minimal installation with network configuration completed, the steps are the same for CentOS 6.

Preparing the system

Upgrade current packages and kernel to the latest version
(I prefer to do this prior to any software installation or configuration on new systems):

yum upgrade

Install required packages

Install CentOS Development Tools for GCC, make, Perl, etc.:

yum groupinstall "Development Tools"

Install additional required packages; kernel-devel, LZO, wget:

yum install kernel-devel lzo wget

Install option packages

Common tape/SCSI utilities:

yum install mtx lsscsi sg3_utils

Installing the mhVTL

Current mhVTL packages can be found at (for this example using build 1.5-4):

Download to temp location


Install RPM packages

rpm -Uvh mhvtl-utils-1.5-4.x86_64.rpm mhvtl-utils-1.5-4.src.rpm

(RPM files can now be removed if wanted)

Build kernel module

cd /root/rpmbuild/SOURCES/
tar xvfz mhvtl-2016-03-10.tgz
cd mhvtl-1.5/kernel/
make install

Start the mhVTL

/etc/init.d/mhvtl start

On first start the mhVTL will generate needed configuration files in /etc/mhvlt/.

You now have a working VTL, confirmation can be done using:


When editing the configuration files, I recommend making a copy of the files so you can restore back should your edited configuration not work.

Set to start on boot

chkconfig mhvtl on

Note on iSCSI Integration

CentOS 7 / RHEL 7

With CentOS 7 and RHEL 7 there is a big change in the management of iSCSI targets. Switching from TGT to LIO moves the target from user space into the kernal.  targetcli is the front-end for viewing, editing, and saving the configuration of the Linux-IO Target (without the need to manipulate the kernel target’s configuration directly).

After a lot of searching there currently there appears to be a limitation with PSCSI (Linux pass-through SCSI devices) Backstores.  “”Note that the pscsi dev= parameter in targetcli assumes a block device (/dev/sdX or /dev/sr), so this currently does not work with SCSI medium changers or tapes that use character devices..””  –

CentOS 6 / RHEL 6

See my guide to setup the mhVTL-GUI web interface and TGTd iSCSI at: Adding a Web GUI to the mhVTL

16 thoughts on “mhVTL on CentOS 6 / 7

  1. Brad Wolfe

    I am really excited about this. Thank you for sharing about how to install on Centos 7. I was able to get it installed on a Centos 7 VM. I am using a Windows Server 2012 R2 VM with Data Protection Manager to connect to it. DPM sees the library and the tapes. It doesn’t see the drives, but I am not concerned about that yet.

    I set this up with many of the defaults and using mhvtl-gui. I am not sure at this point how to configure the library to point to specific hard drive space for its tape-files. It looks like it is utilizing /opt/mhvtl as its files for tape storage. I would like to know if there is a way to configure a different storage location. Right now this resides on the root file system and it isn’t very large. I have several VHDs attached that I’d like to utilize instead. I don’t seem to recall having a choice of where to store these tape files. I hope this makes sense. It may just mean that I do not understand how this works.
    Thanks for your help!

    1. Max Post author

      Hi Brad, there are a couple of options to redirect the storage from /opt/mhvtl.

      First you can use a symbolic link to point /opt/mhvtl to another path such as /vtl which is mounted to another disk.
      For example, on one of my lab machines I have a second virtual disk of 16 GB /dev/sdb1 mounted to /VTL.

      [root@maxm-nb /]# df -h
      Filesystem Size Used Avail Use% Mounted on
      /dev/sdb1 16G 7.4G 7.5G 50% /VTL

      Using a symbolic link I have pointed /opt/mhvtl to /VTL

      [root@maxm-nb opt]# ls -l
      total 0
      lrwxrwxrwx. 1 root root 4 Sep 24 11:02 mhvtl -> /VTL

      Second, while the above will redirect all contents of /opt/mhvtl, you can choose a different path to store the VTL tapes per library by editing /etc/mhvtl/device.conf to include a different home directory path (for each library). Example below changing library 10 from /opt/mhvtl to /VTL.

      Library: 10 CHANNEL: 00 TARGET: 00 LUN: 00
      Vendor identification: STK
      Product identification: L700
      Unit serial number: XYZZY_A
      NAA: 10:22:33:44:ab:00:00:00
      Home directory: /VTL
      PERSIST: False
      Backoff: 400
      # fifo: /var/tmp/mhvtl

  2. Pingback: Adding a Web GUI to the mhVTL | Tech2Max

  3. Ron

    Dear Max,

    how is it possible to recreate all Vtapes again with a new size? I changed the size in the config file to 4096 but how can I update all existing tapes in centOS7?

    1. Max Post author

      Hi Ron, after changing the value in /etc/mhvtl.conf, if the existing data on the tapes is of no value, simply stop the VTL (/etc/init.d/mhvtl stop) and delete the tapes from /opt/mhvtl (default location). Upon starting the VTL again (/etc/init.d/mhvtl start) the tapes will be recreated as new using the new value. You may need to re-scan your library from your backup software. This is also a good time to edit the library_contents file to add tapes, change bar codes, etc.

      1. Max Post author

        After discussing with Mark (of the mh in mhVTL) if you wanted to change the size of a single tape, the edit_tape command can be used as such: “edit_tape -l Library-ID -m Media-ID -s Size-in-MB“.

  4. JS

    Very helpful, thank you.

    On my system, I needed theses as well:
    yum install zlib-devel.x86_64
    yum install lzo-devel.x86_64

    1. Max Post author

      Just checked a 7.2.1511 box and I don’t have either of those installed. I know lzo is required by the development package shouldn’t be needed. Out of curiosity, are you installing on CentOS or RedHat and at what version?

  5. Ralf Krause

    Absolutely great. Following these steps I was able to setup mhvtl on my CentOS 7 system without problems.

    1. Max Post author

      Hi Ralf, glad to here it worked for you with no issues. Thanks for the feedback.

  6. Chima

    Great tutorial. Am trying out this and am having issues with buling Kernal Module

    The command “make” and “Make Install” gives errors as below:
    make: *** /lib/modules/3.10.0-514.10.2.el7.x86_64/build: No such file or directory. Stop.
    make: *** [default] Error 2
    [root@vultr kernel]# make install
    install -o root -g root -m 644 mhvtl.ko /lib/modules/`uname -r`/kernel/drivers/scsi/; \
    depmod -a; \
    if [ -f “/etc/modprobe.d/unsupported-modules” ]; then \
    sed -i ‘s/^allow_unsupported_modules 0/allow_unsupported_modules 1/’ /etc/modprobe.d/unsupported-modules; \
    install: cannot stat ‘mhvtl.ko’: No such file or directory

    1. Max Post author

      Hello Chima,

      Can you please confirm the version of CentOS you are using?
      cat /etc/centos-release

      And that you have the development tools installed?
      yum group info "Development Tools"

      1. Chima

        Thank you for replying.

        my version of centos is: CentOS Linux release 7.3.1611 (Core)

        and I did install the development tool

  7. Sedman

    Great walk through, I was able to set it up without a problem on Centos 7.3
    I’m sure your time has been appreciated by many, including myself. (really like your template/theme/layout – very readable.)

    I’m wondering though, its been a while since you originally wrote this… have you managed to come up with a solution to enable mhvtl with targetcli? I’m looking at TCMU-runner, and it looks like it could provide the abstraction layer, but I’m a hobbyist at best with these things.

    1. Max Post author

      Hello, no unfortunately I have not had any time to devote/investigate this. I will pass on the feedback to Mark.


Leave a Reply

Your email address will not be published. Required fields are marked *