Tape Drives
Note: Article about the outdated Proxmox VE 1.x releases |
Introduction
In some situations its needed to have access to a directly attached tape drive in a KVM guest. Main reason is to run a backup software in a KVM guest using the tape drive physically connected to the Proxmox VE host.
Note: you need to run the latest Proxmox VE 1.4 to use tape drives
Using Tape Drives as iSCSI target (for Windows KVM guests)
For this article we tested with Symantec Backup Exec 12.5, running in a Win2008 R2 guest and a HP Ultrium 3 drive. We suggest to setup an iSCSI target which exports the tape drive (on the Proxmox VE host). That way you can access the tape inside the VM with the standard iSCSI initiator (already included in Windows 2008). The Proxmox kernel already includes all needed iSCSI target modules. You just need to install 2 additional packages:
# apt-get install iscsi-scst scstadmin
The following command should list the scsi address of your tape drive
# cat /proc/scsi_tgt/scsi_tgt |grep tape 0:0:3:0 dev_tape
Then edit the SCST configuration file /etc/scst.conf to export above address:
[HANDLER tape] DEVICE 0:0:3:0 [ASSIGNMENT Default] DEVICE 0:0:3:0,0
After that you need to reload the configuration:
/etc/init.d/scst reload
Now the tape is exported and accessible via iSCSI. You may also want to setup access control with /etc/initiators.allow or /etc/initiators.deny, or add additional target setting in /etc/iscsi-scstd.conf. For details see http://scst.sourceforge.net/
The directory /proc/scsi_tgt/ contains the scsi target status (useful for debugging). Also check the output of 'dmesg'.
Usermode iSCSI target (export) software
If you have problems with the kernel mode "scst" software, or wish to export drives from other machines where that software is not readily available, then it is possible to pass-through tape drives using the usermode stgt software v1.0.8 or later instead (see http://stgt.sourceforge.net/ ) using a script like this:
# # Export the first tape drive via iSCSI as a passthrough device, and enable # header digests, whilst limiting access to a single IP address. # TAPEDRIVESG=$(lsscsi -g | awk '$2 == "tape" { print $NF; exit}') INITIATORHOST=192.168.0.42 /usr/local/bin/tgtd && \ /usr/local/bin/tgtadm --lld iscsi --mode target --op new --tid=1 --targetname iqn.2009-02.com.debian:tapedrive && \ /usr/local/bin/tgtadm -d --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 --backing-store=${TAPEDRIVESG} --bstype=sg --device-type=pt && \ /usr/local/bin/tgtadm --lld iscsi --mode target --op update --tid 1 --name HeaderDigest --value CRC32C && \ /usr/local/bin/tgtadm --lld iscsi --mode target --op bind --tid 1 -I ${INITIATORHOST}
Windows iSCSI initiator
For Windows XP/2003, Microsoft offers a free software initiator. Just install and connect as usual and you will see the tape drive in the device manager. Win2008/Vista/Win7 already includes the iSCSI initiator software. We noticed a quite unstable iSCSI in Windows 2003 but very stable iSCSI in Windows 2008 R2.
Linux iSCSI initiator
On Linux, use the open-iscsi initiator.
Using Tape Drives as SCSI pass through (for Linux KVM guests)
Above method also works with Linux using the open-iscsi initiator.
Another way it to use SCSI pass-through. You first need to find out which (generic) scsi device is assigned to your tape. On my system this is 'sg0'
# cat /sys/class/scsi_generic/sg0/device/model Ultrium 3-SCSI
Now edit the VM config file directly (/etc/qemu-server/XXX.conf) and add a line
scsi0: /dev/sg0
Then stop and start the VM again (a simple reboot is not enough).
Using Tape Drives via PCI pass through with extra SCSI controller
not implemented yet.