Penguin

ntpdate(1) has no effect

Xen by default just uses the dom0's clock, which isn't updated within the domU's. Either set /proc/xen/independent_wallclock to 1 (so that this domU has an indepedent clock from the host dom0, or set the clock in the dom0.

Making a tape drive available to a guest via iSCSI Xenserver5.6

Making a tape drive available to a guest via iSCSI
This is specifically for Citrix XenServer, although the principles will of course work in other Xen implementations

I recently had a scenario where I was replacing two Windows servers with XenServer guests. This was fine, but we needed a way to backup to the existing SCSI DDS4 DAT drive. After failing to make PCI passthrough work, I settled on the much nicer method of providing the tape drive via an iSCSI target on the XenServer Host (Dom0). Here is how I achieved this.

NOTE WELL: This method replaces the old one using a patched ietd. It is STILL unsupported

•Download and install the DDK machine from citrix.com
•Download the following packages to the DDK from http://scst.sourceforge.net/downloads.html


You can get the SCST source files from http://scst.sourceforge.net/downloads.html
As I want a stable platform I use the downloads from "Download released versions"
For the iscsi-target we need three files: scst, iscsi-scst and scstadmin.
You can get these files in varios ways, in the example they are downloaded with links.
If links is not already installed install it:
'emerge links'
Go the the directory where you want the files (the example uses /opt/build) and get the files:
'cd /root'
'links http://scst.sourceforge.net/downloads.html'
and download under stable the three needed files, at this moment they are scst-1.0.1.1.tar.gz, scstadmin-1.0.6.tar.gz and iscsi-scst-1.0.1.1.tar.gz
after downloading exit links:
'q'

•Extract them in a build directory (I'm using /opt/build)


 Now extract the three downloaded files
'tar -zxf scst-1.0.1.1.tar.gz'
'tar -zxf scstadmin-1.0.6.tar.gz'
'tar -zxf iscsi-scst-1.0.1.1.tar.gz'

•Edit the scst-1.0.1.1/src/Makefile and uncomment the line EXTRA_CFLAGS += -DCONFIG_SCST_STRICT_SERIALIZING

Here's where it gets a little ugly, and I'd welcome suggestions (just edit this wiki) for how to do this the "right" way. This is necessary because the make install part of the build depends on having the kernel-dev skeleton installed, and this can't be installed on a XenServer Host (to my knowledge).

•tar up the devel tree - example (the dir will change depending on the XenServer/kernel version):
cd /usr/src/kernels/2.6.18-128.1.6.el5.xs5.5.0.505.1024xen-i686
tar -czvpf /opt/build/build.tar.gz .
cd /opt/build

Ok now time to move to your Xenserver host.

•Copy the entire /opt/build dir to the target host and execute the following steps ($kern is the version you used above):
yum --enablerepo=base install gcc make patch m4 openssl-devel yum-utils
. /etc/xensource-inventory
if [ "$PRODUCT_VERSION" == "5.6.0" ] ; then
        yum -y --enablerepo=base install yum-utils
        yumdownloader --enablerepo=base e2fsprogs-devel
        rpm --nodeps -Uvh e2fsprogs-devel*.rpm
        rm -f e2fsprogs-devel*.rpm
fi
yum --enablerepo=base install gcc make patch m4 openssl-devel yum-utils
mkdir /lib/modules/$kern/build
cd /lib/modules/$kern/build
tar -zxvf /opt/build/build.tar.gz
cd /opt/build

cd scst-1.0.1.1/src
make all
make install
depmod -aq

cd ../scstadmin-1.0.6
make all
make install
Remove the scst_disk module from the startup file
vi /etc/init.d/scst
change the line SCST_MODULES="scst scst-disk scst_vdisk" to SCST_MODULES="scst scst-disk scst_vdisk scst_tape"

cd /opt/build/iscsi-scst-1.0.1.1
make all
make install
cp etc/initiators.* /etc
cp etc/iscsi-scstd.conf /etc
depmod -aq

Now have a look in /proc/scsi/scsi (or use lsscsi) to get your HCIL info for your tape drive and create /etc/scst.conf using THAT info, NOT the example info given here...

[HANDLER tape]
DEVICE 6:0:3:0

[ASSIGNMENT Default]
DEVICE 6:0:3:0,0

•Now create /etc/iscsi-scstd.conf similar to the following
echo "Target $(sed -n 's/InitiatorName=//p' /etc/iscsi/initiatorname.iscsi):storage" >/etc/iscsi-scstd.conf

Target iqn.2005-03.org.open-iscsi:76cf8781117f:storage•Ensure you have TCP port 3260 open in /etc/sysconfig/iptables and run service iptables restart
•Finally, set the relevant daemons to start on boot with chkconfig scst on && chkconfig iscsi-scst on (and start them with service scst start && service iscsi-scst start)
You should now be able to discover and connect to the target.

Tested using MS iSCSI initiator on Windows Server 2008 against the above config on XenServer 5.6.

Making a tape drive available to a guest via iSCSI

This is specifically for Citrix XenServer, although the principles will of course work in other Xen implementations

I recently had a scenario where I was replacing two Windows servers with XenServer guests. This was fine, but we needed a way to backup to the existing SCSI DDS4 DAT drive. After failing to make PCI passthrough work, I settled on the much nicer method of providing the tape drive via an iSCSI target on the XenServer Host (Dom0). Here is how I achieved this.

NOTE WELL: This method replaces the old one using a patched ietd. It is STILL unsupported

  • Download and install the DDK machine from citrix.com
  • Download the following packages to the DDK from http://scst.sourceforge.net/downloads.html

    • scst
    • iscsi-scst
    • scstadmin
  • Extract them in a build directory (I'm using /opt/build)
  • Edit the scst-1.0.1.1/src/Makefile and uncomment the line EXTRA_CFLAGS += -DCONFIG_SCST_STRICT_SERIALIZING
  • Now, in order, do a make and make install for scst, iscsi-scst, and scstadmin (you need the install, even though it's on the DDK for the deps of iscsi-scst)

Here's where it gets a little ugly, and I'd welcome suggestions (just edit this wiki) for how to do this the "right" way. This is necessary because the make install part of the build depends on having the kernel-dev skeleton installed, and this can't be installed on a XenServer Host (to my knowledge).

  • tar up the devel tree - example (the dir will change depending on the XenServer/kernel version):
cd /usr/src/kernels/2.6.18-128.1.6.el5.xs5.5.0.505.1024xen-i686
tar -czvpf /opt/build/build.tar.gz .
cd /opt/build

OK, you're now ready to install on your target XenServer? host

  • Copy the entire /opt/build dir to the target host and execute the following steps ($kern is the version you used above):
yum --enablerepo=base install gcc make patch m4 openssl-devel yum-utils
. /etc/xensource-inventory
if [ "$PRODUCT_VERSION" == "5.6.0" ] ; then
        yum -y --enablerepo=base install yum-utils
        yumdownloader --enablerepo=base e2fsprogs-devel
        rpm --nodeps -Uvh e2fsprogs-devel*.rpm
        rm -f e2fsprogs-devel*.rpm
fi
mkdir /lib/modules/$kern/build
cd /lib/modules/$kern/build
tar -zxvf /opt/build/build.tar.gz
cd /opt/build
cd scst-1.0.1.1
make install
cd ../scstadmin-1.0.6
make
make install
cd ../iscsi-scst-1.0.1.1
make
make install

Now have a look in /proc/scsi/scsi (or use lsscsi) to get your HCIL info for your tape drive and create /etc/scst.conf using THAT info, NOT the example info given here...

[HANDLER tape]
DEVICE 6:0:3:0

[ASSIGNMENT Default]
DEVICE 6:0:3:0,0
  • Now create /etc/iscsi-scstd.conf similar to the following (I generated mine using the method found here)
Target iqn.2005-03.org.open-iscsi:76cf8781117f:storage
  • Ensure you have TCP port 3260 open in /etc/sysconfig/iptables and run service iptables restart
  • Finally, set the relevant daemons to start on boot with chkconfig scst on && chkconfig iscsi-scst on (and start them with service scst start && service iscsi-scst start)

You should now be able to discover and connect to the target.

Tested using MS iSCSI initiator on Windows Server 2008 against the above config on XenServer 5.5.

I note this page is referenced A LOT from Citrix and other sites. It is very important to note this is NOT supported by Citrix. It would be great if they provided this ability natively, to save me the ton of work I've had to do retesting the old solution and finally developing this one (well, I developed nothing, just put it all together, but still...). If this is useful to anyone out there, I'm a huge beer nerd, and love great craft beer from all over the world. If you want to say thanks, you can send beer to:

Greig McGill?
23 Saxbys Road
Hamilton 3206
New Zealand

If you can't be arsed sending me a nice beer, well, I never thought you would anyway! :)

The old method below works on XenServer? pre 5.0

Note 1: This is totally unsupported by Citrix

Note 2: I've used the XenServer terminology "host" instead of Dom0, as this applies to the Citrix commercial implementation of Xen. It will probably work fine on OSS Xen, but you can just install the normal kernel dev packages and ignore the DDK stuff.

Note 3: This is for XenServer 4.1.0, but the principles are the same for previous versions. Just ensure you understand each step rather than following blindly.

Note 4: You'll need to enable yum repositories. Do this by editing /etc/yum.repos.d/CentOS-Base.repo, and set "enabled=1" for the Base, Updates and Addons repositories

Note 5: Thanks to the wonderful work of Blake-r the rawio patch has now been updated to work against iscsitarget-0.4.17 - when using this against a kernel newer than 2.6.22, you'll need to edit kernel/target_raw.c and replace all the psg.page occurrences with psg.page_link due to changes in the scatterlist struct. To take advantage of this, just substitute the newer versions of iscsitarget and the rawio patch in these instructions. You should be able to keep all the instructions the same, but I've not tested this yet.

yum install kernel-devel bison flex
tar -zxvf iscsitarget-0.4.14.tar.gz
cd iscsitarget-0.4.14
patch -p0 < /tmp/raw.p
make
  • scp the entire iscsitarget-0.4.14 directory to your destination Xen host, and on that host (after enabling the base repo in /etc/yum.repos.d/CentOS-Base.repo) do:
yum install make gcc
cd iscsitarget-0.4.14
make install
mkdir /lib/modules/`uname -r`/kernel/iscsi
cp kernel/iscsi_trgt.ko /lib/modules/`uname -r`/kernel/iscsi
depmod -aq

The last three steps are required because make install will not copy the kernel module correctly outside the target environment.

  • Now edit your /etc/ietd.conf and configure the tape as per the following example snippet (cat /proc/scsi/scsi for the correct HCIL values for your SCSI tape drive, this is an example only):
Target iqn.2007-04.com.example:tape0
     Lun 0 H=1,C=0,I=6,L=0,Type=rawio
     Type 1
  • Save and do /etc/init.d/iscsi-target start
  • Modify /etc/sysconfig/iptables to allow port 3260 tcp from the IP addresses running the initiator.
  • Attach to the target using the initiator of your choice.

Working around pesky controllers which change HCIL at boot

See the following, requested by Simon Larsen at http://fragged.nu/2009/05/making-a-tape-drive-available-to-a-guest-via-iscsi/

Simon, if you read this, your captcha on your blog is broken, preventing comments, and there's no contact email address. Hope you find this, and find it useful. ;)

Just bung it in your rc.local.

#!/bin/bash
#
# This script is a (very) primitive method of determining the current HCIL info
# for /etc/ietd.conf (config file for iscsi-target) to work around some
# controllers which change this ID at boot time. You'll probably want to add
# some data validation of those vars as this is purely for my environments.
# Feel free to adapt or use it in any way you see fit.
# Greig McGill. August, 2009

# First set some vars

ietd="/etc/ietd.conf"
iqn="iqn.2009-08.nz.org.aol.internal:tape0"

# Get the whole HCIL string representing the tape drive.
# IMPORTANT NOTE: I am assuming there is only one sequential access device.
# If I am wrong, you WILL need to rewrite this, or badness will happen.
# You have been warned.

HCIL="`cat /proc/scsi/scsi | grep -B2 Sequential | head -1`"

# Now get each component

H="`echo $HCIL | cut -c 11`"
C="`echo $HCIL | cut -c 23`"
I="`echo $HCIL | cut -c 30`"
L="`echo $HCIL | cut -c 38`"

# Got all that, now generate ietd.conf and restart iscsi-target

cat <<EOT >$ietd
Target $iqn
        Lun 0 H=$H,C=$C,I=$I,L=$L,Type=rawio
        Type 1
EOT

/etc/init.d/iscsi-target restart

# exit with no error

exit 0

See iSCSINotes as well for more information


CategoryXen