Booting from iSCSI with Debian Lenny

Introduction

This howto is similar to how to get iSCSI working with Debian Etch. It is important to note the following differences from that howto:

  • The fwparam_ibft utility used in the initrd scripts in the Debian Etch solution does not exist anymore. Its functionality has changed slightly, and it has been merged into the other tool called iscsistart. To test it simply say iscsistart -f. Both utilites are/were part of the Open-iSCSI software.
  • While the iSCSI + Etch guide told you to compile the open-iscsi tools from source because the iscsistart and fwparam_ibft tools were missing from the package, Lenny actually has the iscsistart in the package called open-iscsi in its repository. Simply say aptitude install open-iscsi to have it installed, and have a look at its its documentation.
  • The open-iscsi package in Lenny also installs iscsi related boot scripts for initrd so you might not have to make your own. However, the devil is in the details below.

Doing iSCSI the lenny way

Install open-iscsi

aptitude install open-iscsi

Touch the indicatorfile, which is queried to determine whether the iscsi tools and scripts are to be copied into the new initrd

touch /etc/iscsi/iscsi.initramfs

Rebuild your initrd.

aptitude install initramfs-tools
update-initramfs -u

Configure the parameters to your kernel with the following goals in mind:

  • The initiator and other iSCSI related parameter should be specified so that the open-iscsi boot scripts can get going with setting up iSCSI
  • The kernel should find the correct disk once iSCSI is online. The safest way is to use a LABEL= or UUID= identification.

Example:

title           Debian Lenny iSCSI
   kernel       /vmlinuz-2.6.28-11-generic ISCSI_INITIATOR=iqn.2009-04.mynet:general iSCSI_TARGET_NAME=iqn.2009-04.mynet.node1:general.vol1 iSCSI_TARGET_IP=192.168.1.1 ISCSI_TARGET_PORT=3260 root=UUID=021ebcfc-188a-41ba-9864-ee18cbf7af9f ro
   initrd       /initrd.img-2.6.28-11-generic

Try to boot!

Lenny doesnt fetch from iBFT

Now if Open-iSCSI is in the repositories then why did I bother to write this howto? Good question! The answer is simply that you don't get the same result with the iSCSI + Etch howto as you get when instlling open-iscsi from the lenny repositories. While the “etch solution” fetches iscsi parameters from the iBFT, the “built-in lenny solution” fetches the parameters from configuration file(s) under /etc/ in the initramfs image itself and/or settings passed as kernel parameters from the bootloader.

While this simple distinction might seem innocent enough, it really isn't. In many cases it is impracticalt to create a new initrd or root image to change the iscsi parameters. Luckily, for most people there is a more elegant way to get the parameters. The latest lenny kernel (as of 4. November 2009) has an iBFT function compiled in that makes fetching the iSCSI parameters from iBFT really easy. From your initrd script, simply traverse the directory /sys/firmware/ibft The files in there contain all the ibft information you could ever want.

FIXME I didn't follow this route, but if you do, please put the initramfs script you created here. You can get access to this wiki by asking in the #etherboot IRC channel at irc.freenode.org. Se below for the route I took, and consequently the script i made instead

UPDATE I found a patch that probably solves this! This patch might help: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=514924#4

Extras: XEN + iSCSI + Lenny + iBFT

I decided to share my experience with iSCSI + Xen on Debian Lenny because that is a very important part of my setup. If you don't know or don't care about Xen you can simply skip this section. In short, I want to configure all my webserver farm nodes to boot xen dom0 kernels over iSCSI for my little webhost company. The problem arises since the xen kernels prior to 2.6.32 does not populate /sys/firmware/ibft directory.

Solutions to XEN + iSCSI + Lenny + iBFT

There are 3 solutions to the problem of aquiering iSCSI data from the iBFT with a lenny XEN kernel in initrd:

  • Fall back to the default behaviour in Lenny, namely to read the settings from configurations in /etc/ and/or settings passed as kernel parameters.
  • Patch the kernel or use an alternate kernle (newer than 2.6.32 or patched) to fix the iBFT + XEN problem. This patch looks promising: http://patchwork.kernel.org/patch/50838/ . Documentation for how to proceed with that is available here: http://wiki.debian.org/DebianKernelCustomCompilation and you might also want to read this: http://packages.debian.org/lenny/kernel-package and this: http://www.debian.org/doc/FAQ/ch-kernel.en.html
  • My favourite: Use an utility that gets hold of the iBFT data without depending on the kernel sysfs directory /sys/firmware/ibft. I did this by fetching an older version of the Open-iSCSI sourcecode from here: http://www.open-iscsi.org/bits/. I have confirmed that the version mentioned in the Etch howto works flawlessly: http://www.open-iscsi.org/bits/open-iscsi-2.0-865.13.tar.gz. I used the Etch howto as a reference when building. You only need to compile the tool called fwparam_ibft as the rest is allready installed in Lenny. This tool gets its iBFT data directly from memory without asking the kernel at all. After compiling the fwparam_ibft tool and copying it to /usr/sbin, make sure to creating these two initramfs hook script which will be executed automatically to include the fwparam_ibft binary in the ramdisk image when initramfs is updated, and to put it to good use at boot time respectively.

/etc/initramfs-tools/hooks/iscsi_tcp

#!/bin/sh
set  -e
PREREQ=""
prereqs()
{
        echo "$PREREQ"
}
case $1 in
prereqs)
        prereqs
        exit 0
        ;;
esac
. /usr/share/initramfs-tools/hook-functions
# NOTE THIS WILL BE INCLUDED BY DEFAULT, SO ITS DISABLED HERE: [ -x /usr/sbin/iscsistart ] && copy_exec /usr/sbin/iscsistart /sbin
[ -x /usr/sbin/fwparam_ibft ] && copy_exec /usr/sbin/fwparam_ibft /sbin
[ -x /sbin/ip ] && copy_exec /sbin/ip /sbin
manual_add_modules iscsi_tcp
manual_add_modules ib_iser

/etc/initramfs-tools/scripts/local-top/iscsi_tcp

This script will run at the correct time during boot to bring up iSCSI. It has been verified to work in a XEN-Dom0 node.

#!/bin/sh
set -e
PREREQ="udev"
prereqs()
{
        echo "$PREREQ"
}
case $1 in
prereqs)
        prereqs
        exit 0
        ;;
esac
 
echo ""
echo "Custom iSCSI Boot script for Debian Lenny starting..."
echo ""
 
modprobe -q iscsi_tcp
modprobe -q ib_iser
 
echo "Evaluating IBFT parameters"
for i in $(fwparam_ibft);
do
	#Strip of namespace
	V=$(echo $i | sed 's|network\([0-9]*\):|iSCSI_INITIATOR_\1_|' | sed 's|target\([0-9]*\):|iSCSI_TARGET_\1_|' | sed 's|iscsi-initiator\([0-9]*\):|iSCSI_INITIATOR_\1_|')
	echo "   Exporting $V"
	export $V;
done
 
echo "Bringing up the interface used to boot"
for i in $(ls /sys/class/net); do
       IFADDR=$(cat /sys/class/net/$i/address)
       if [ $IFADDR = $iSCSI_INITIATOR_0_HWADDR ]; then
               echo "   Using $i with MAC $IFADDR"
               export iSCSI_INITIATOR_0_IF=$i
       fi
done
 
echo "   Bringing up $iSCSI_INITIATOR_0_IF for iSCSI..."
ip link set $iSCSI_INITIATOR_0_IF up
 
echo "   Setting up networking on $iSCSI_INITIATOR_0_IF..."
ip addr add $iSCSI_INITIATOR_0_IPADDR/$iSCSI_INITIATOR_0_MASK brd + dev $iSCSI_INITIATOR_0_IF
ip route add default via $iSCSI_INITIATOR_0_GATEWAY
 
echo "Connecting to iSCSI target $iSCSI_TARGET_0_NAME on $iSCSI_TARGET_0_IPADDR..."
iscsistart -i $iSCSI_INITIATOR_0_NAME -t $iSCSI_TARGET_0_NAME -g 1 -a $iSCSI_TARGET_0_IPADDR
sleep 5

Important: remember to chmod +x both these scripts so that the are executable before updating your initrd

Conclusion

Configuring boot over iSCSI work in Debian Lenny can potentially be much easier than it was in Etch because of the built-in support for iSCSI boot made by Debian devs in Lenny. If you only have a few servers that you need to boot over iSCSI then using this metod is simple to set up and probably works great.

However if you have a setup with many computers (cluster) or need a more elegant way to manage your boot parameters for another reason then you will need to modify the default behaviour in Lenny, and this requires about half the amount of fiddeling required with Debian Etch.

However if you decide to boot XEN nodes like I showed in this example you need to fiddle just as much if not more than the Etch howto described :)


Navigation

* [[:start|Home]] * [[:about|About our Project]] * [[:download|Download]] * [[:screenshots|Screenshots]] * Documentation * [[:howtos|HowTo Guides]] * [[:appnotes|Application Notes]] * [[:faq:|FAQs]] * [[:doc|General Doc]] * [[:talks|Videos, Talks, and Papers]] * [[:hardwareissues|Hardware Issues]] * [[:mailinglists|Mailing lists]] * [[http://support.etherboot.org/|Bugtracker]] * [[:contributing|Contributing]] * [[:editing_permission|Wiki Edit Permission]] * [[:wiki:syntax|Wiki Syntax]] * [[:contact|Contact]] * [[:relatedlinks|Related Links]] * [[:commerciallinks|Commercial Links]] * [[:acknowledgements|Acknowledgements]] * [[:logos|Logo Art]]

QR Code
QR Code sanboot:debian_lenny_iscsi (generated for current page)