Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
sanboot:debian_lenny_iscsi [2009/11/22 05:15]
garlopf
sanboot:debian_lenny_iscsi [2009/11/23 17:00]
garlopf
Line 38: Line 38:
  
 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. 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.
- 
-<code bash> 
-TODO: post an initrd hook/script that does exactly that 
-</​code>​ 
  
 ==== Extras: XEN + iSCSI + Lenny + iBFT ==== ==== Extras: XEN + iSCSI + Lenny + iBFT ====
  
-I decided to share my experience with iSCSI + [[http://​xen.org/​|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 [[http://​colobg.net/​|webhost company]]. The problem arises since the xen kernels prior to 2.6.32 does not populate ''/​sys/​firmware/​ibft ​directory''​.+I decided to share my experience with iSCSI + [[http://​xen.org/​|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 [[http://​colobg.net/​|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 ==== ==== 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: There are 3 solutions to the problem of aquiering iSCSI data from the iBFT with a lenny XEN kernel in initrd:
   * Patch the kernel or use an alternate kernel 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   * Patch the kernel or use an alternate kernel 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
-  * Use an utility that gets hold of the iBFT data without depending on the kernel sysfs directory ''/​sys/​firmware/​ibft''​. One way that has been tested and that works is to do that is to fetch an older version of the Open-iSCSI sourcecode from here: http://​www.open-iscsi.org/​bits/​ and compiling the old fwparam_ibft tool that is mentioned in the etch howto. This tool gets its iBFT data directly from memory without asking the kernel at all. This has been confirmed ​to work with an XEN dom-0 kernel.+  * Use an utility that gets hold of the iBFT data without depending on the kernel sysfs directory ''/​sys/​firmware/​ibft''​. One way that has been tested and that works is to do that is to fetch an older version of the Open-iSCSI sourcecode from here: http://​www.open-iscsi.org/​bits/​ and compiling the old fwparam_ibft tool that is mentioned in the etch howto
 + 
 +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. This tool gets its iBFT data directly from memory without asking the kernel at all. After compiling the fwparam_ibft tool, make sure its included in the initramfs by creating these hook script which will automatically be executed when you rebuild your initramfs, and at boot time respectively. 
 +=== /​etc/​initramfs-tools/​hooks/​iscsi_tcp === 
 +<code bash> 
 +#!/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 
 +</​code>​ 
 +=== /​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. 
 +<code bash> 
 +#!/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 
 + 
 +</​code>​ 
 +**Important:​ remember to ''​chmod +x''​ both these scripts so that the are executable before updating your 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.   * Fall back to the default behaviour in Lenny, namely to read the settings from configurations in ''/​etc/''​ and/or settings passed as kernel parameters.
  

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