Skip to content

Instantly share code, notes, and snippets.

@bitsgalore
Last active December 5, 2018 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitsgalore/f02e37aba6de988c8ae173a1307c73ff to your computer and use it in GitHub Desktop.
Save bitsgalore/f02e37aba6de988c8ae173a1307c73ff to your computer and use it in GitHub Desktop.
Mhvtl virtual tape library notes

mhvtl notes

https://github.com/markh794/mhvtl

Installation

Install script for Ubuntu 16.04:

https://gist.github.com/hrchu/3eb1c0aa9994df0328037fff04cd889d

Using mhvtl

Start the tape library:

sudo /etc/init.d/mhvtl start

List all devices:

lsscsi -g

Result:

[0:0:0:0]    disk    ATA      TOSHIBA DT01ACA1 A800  /dev/sdb   /dev/sg1 
[1:0:0:0]    cd/dvd  hp       DVDRW  DU8A6SH   DHS3  /dev/sr0   /dev/sg2 
[4:0:0:0]    disk    Seagate  Expansion        0636  /dev/sda   /dev/sg0 
[5:0:0:0]    mediumx STK      L700             0105  /dev/sch0  /dev/sg11
[5:0:1:0]    tape    IBM      ULT3580-TD5      0105  /dev/st0   /dev/sg3 
[5:0:2:0]    tape    IBM      ULT3580-TD5      0105  /dev/st1   /dev/sg4 
[5:0:3:0]    tape    IBM      ULT3580-TD4      0105  /dev/st2   /dev/sg5 
[5:0:4:0]    tape    IBM      ULT3580-TD4      0105  /dev/st3   /dev/sg6 
[5:0:8:0]    mediumx STK      L80              0105  /dev/sch1  /dev/sg12
[5:0:9:0]    tape    STK      T10000B          0105  /dev/st4   /dev/sg7 
[5:0:10:0]   tape    STK      T10000B          0105  /dev/st5   /dev/sg8 
[5:0:11:0]   tape    STK      T10000B          0105  /dev/st6   /dev/sg9 
[5:0:12:0]   tape    STK      T10000B          0105  /dev/st7   /dev/sg10

Here /dev/sg11 (scsi device /dev/sch0) is the tape robot, and /dev/sg3 (scsi /dev/st0) to /dev/sg6 (scsi /dev/st3) are its underlying tape devices.

The virtual devices are defined in /etc/mhvtl/device.conf. Below the entry for the first listed tape drive:

Drive: 11 CHANNEL: 00 TARGET: 01 LUN: 00
Library ID: 10 Slot: 01
Vendor identification: IBM
Product identification: ULT3580-TD5
Unit serial number: XYZZY_A1
NAA: 10:22:33:44:ab:00:01:00
Compression: factor 1 enabled 1
Compression type: lzo
Backoff: 400
# fifo: /var/tmp/mhvtl

Config file /etc/mhvtl/library_contents.10 maps slots against virtual tapes. For slot (which is the slo used by the tape drive entry above) we see:

Slot 1: E01001L4

Here E01001L4 is a tape barcode which has a directory of the same name under /opt/mhvtl/. So, data for this virtual tape will be stored in directory /opt/mhvtl/E01001L4.

Load first tape into first drive:

sudo mtx -f /dev/sg11 load 1 0

Result:

Loading media from Storage Element 1 into drive 0...done

Check status:

sudo mtx -f /dev/sg11 status

Result:

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 
    :: ::
    etc.

Write something to tape in first tape device (note we're using the scsi device name!):

sudo tar -cvf /dev/nst0 -b2 /home/johan/jpylyzer-homepage
sudo tar -cvf /dev/nst0 -b8 /home/johan/forensicImagingResources
sudo tar -cvf /dev/nst0 -b16 /home/johan/jpylyzer-homepage

To continue first unload the tape:

sudo mtx -f /dev/sg11 unload 1 0

Reload it:

sudo mtx -f /dev/sg11 load 1 0

Then run tapeimgr. Works!

Resources

https://karellen.blogspot.com/2012/01/mhvtl-virtual-tape-library.html

http://mhvtl-a-linux-virtual-tape-library.966029.n3.nabble.com/Emulating-a-single-drive-no-library-td4025478.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment