Differences

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

Link to this comparison view

Next revision
Previous revision
Last revision Both sides next revision
sanboot:ubuntu_iscsi2 [2010/09/22 07:34]
qiet72 created
sanboot:ubuntu_iscsi2 [2011/01/13 14:36]
cinquero [Random Notes]
Line 1: Line 1:
-====== Getting iSCSI booting to work with Ubuntu ​Lucid Lynx 10.04 ====== +====== Getting iSCSI booting to work with Ubuntu ​including logon and ibft support! ​======
-**(Including logon and ibft support!)**+
  
  
 +**Tested on the following releases:**
 +   * Lucid Lynx 10.04
 +   * Maverick Meerkat 10.10
 +
 +== For this example, I will use these values: ==
  
-For this example, I will use these values: 
    * iSCSI Qualified Name: iqn.2010-09.org.test:​diskimg    * iSCSI Qualified Name: iqn.2010-09.org.test:​diskimg
    * Server ip: 192.168.1.1    * Server ip: 192.168.1.1
Line 32: Line 35:
 </​code>​ </​code>​
  
-** Use the following steps to make the Ubuntu client iSCSI capable: ​**+==== Use the following steps to make the Ubuntu client iSCSI capable: ​==== 
  
 == Paste the following code into a new file called /​etc/​initramfs-tools/​hooks/​iscsi:​ == == Paste the following code into a new file called /​etc/​initramfs-tools/​hooks/​iscsi:​ ==
Line 56: Line 60:
 . /​usr/​share/​initramfs-tools/​hook-functions . /​usr/​share/​initramfs-tools/​hook-functions
 copy_exec /​sbin/​iscsistart /sbin copy_exec /​sbin/​iscsistart /sbin
 +
 +# Disable stuff that can affect the network interface
 +if [ -x /​usr/​lib/​pm-utils/​power.d/​disable_wol ]; then
 +   chmod -x /​usr/​lib/​pm-utils/​power.d/​disable_wol ​        # affects usb network adapters
 +fi
 +if [ -x /​sbin/​iscsid ]; then
 +   chmod -x /​sbin/​iscsid ​                                 # iscsid will interfere by re-discovering
 +fi
 +if [ -e /​lib/​udev/​rules.d/​75-persistent-net-generator.rules ]; then
 +   rm /​etc/​udev/​rules.d/​70-persistent-net.rules ​          # prevent renaming of the network interfaces
 +   rm /​lib/​udev/​rules.d/​75-persistent-net-generator.rules # prevent re-creating the above rule
 +fi
 +
 +# pcmcia/​cardbus networking
 +copy_exec /​lib/​udev/​pcmcia-socket-startup
 +copy_exec /​lib/​udev/​pcmcia-check-broken-cis
 +copy_exec /​lib/​udev/​rules.d/​85-pcmcia.rules
 +copy_exec /​etc/​pcmcia/​config.opts
 +copy_modules_dir kernel/​drivers/​pcmcia
 +copy_modules_dir kernel/​drivers/​net/​pcmcia
 +for x in pcmcia_core yenta_socket pcmcia; do
 +   ​force_load ${x}
 +done
 +
 +# usb networking
 +copy_modules_dir kernel/​drivers/​net/​usb
 +
 +# iscsi module dependencies
 for x in scsi_transport_iscsi libiscsi libiscsi_tcp iscsi_tcp \ for x in scsi_transport_iscsi libiscsi libiscsi_tcp iscsi_tcp \
    ​crc32c iscsi_ibft; do    ​crc32c iscsi_ibft; do
Line 66: Line 98:
 #!/bin/sh #!/bin/sh
  
-Do the following so we do not get errors when doing '​update-initramfs ​-u' +Check if are in the initramfs ​environment 
-if [ "​$BOOT"​ = "​local"​ ]; then +if [ "​$BOOT"​ = "​local"​ ]; then 
-   exit 0 +   # Get any iscsi command line parameters - cmdline parsing template taken from init script in initramfs 
-fi+   for x in $(cat /​proc/​cmdline);​ do 
 +      case $x in 
 +            iscsi_ip=*) 
 +               ​iscsi_ip=${x#​iscsi_ip=} 
 +               ;; 
 +            iscsi_iqn=*) 
 +               ​iscsi_iqn=${x#​iscsi_iqn=} 
 +               ;; 
 +            iscsi_user=*) 
 +               ​iscsi_user=${x#​iscsi_user=} 
 +               ;; 
 +            iscsi_pw=*) 
 +               ​iscsi_pw=${x#​iscsi_pw=} 
 +               ;; 
 +      esac 
 +   done # end of cmdline parsing 
 +   if [ -n "​${iscsi_ip}"​ ]; then 
 +      iscsi_name='​iqn.2000-09.org.local:​UNKNOWN'​ 
 +   fi
  
-# Check if the target ​exists ​then start iscsi +   # Check if an iscsi environment ​exists ​and start up the networking environment 
-if [ -e /​sys/​firmware/​ibft/​target0/​target-name ]; then +   ​if [ -e /​sys/​firmware/​ibft/​target0/​target-name ​-o -n "​${iscsi_ip}" ​]; then 
-   udevadm settle ​--timeout=30    ​wait for netcard +      x=5 
-   ​#ip link set eth0 mtu 2500     ​# Optional: increase mtu for performance +      # Wait up to x seconds for a network interface to pop up 
-   ​ip link set eth0 up            # bring the network interface ​up +      echo -n "​Searching for network cards..."​ 
-   sleep 5                        # wait for the ethernet ​interface ​to come up +      until ifconfig ​-a|grep -q Ethernet; do 
-   ​ipconfig -t 10 -c dhcp -d eth0 get an IP +         sleep 1 
-   ​#iscsistart -b                 ​# This should get the ibft parameters but it does not work for me +         echo -n . 
-                                  # Lets do the following instead +         x=$(($x - 1)) 
-   ​iscsistart \ +         if [ $x = 0 ]; then 
-    -i `cat /​sys/​firmware/​ibft/​initiator/​initiator-name` \ +            echo "No network cards detected!"​ 
-    -t `cat /​sys/​firmware/​ibft/​target0/​target-name` \ +            exit 0 
-    -a `cat /​sys/​firmware/​ibft/​target0/​ip-addr` \ +         fi 
-    -u `cat /​sys/​firmware/​ibft/​target0/​chap-name` \ +      done end of until 
-    -w `cat /​sys/​firmware/​ibft/​target0/​chap-secret` \ +      echo "​Searching ​for an dhcp server on all network interfaces..."​ 
-    -g 1 +      ​CNT=5 
-fi+      until ifconfig ${netdev}|grep -q "inet addr"; do 
 +         for netdev in `ifconfig -a|grep Ethernet|cut -d' ' -f1`; do # Do a round-robin search for dhcp servers 
 +            ​#ip link set ${netdev} ​mtu 2500                          # Optional: increase mtu for performance 
 +            ip link set ${netdev} ​up                                 ​try to bring up the interface 
 +            ipconfig -t -c dhcp -d ${netdev} ​                      Get an IP 
 +            if ifconfig -a|grep -q "inet addr"; then break 2; fi     # If we have got an address, stop searching. 
 +         done # end of netdev probing 
 +         ​CNT=$((${CNT} - 1)) 
 +         if [ ${CNT} = 0 ]; then 
 +            echo "No dhcp servers found!"​ 
 +            exit 0 
 +         fi 
 +         echo "Tries left: ${CNT}"​ 
 +      done # end of until 
 +      if [ -e /​sys/​firmware/​ibft/​target0/​target-name ]; then 
 +         #iscsistart -b  # This should get the ibft parameters but it does not yet. 
 +         ​# Lets do the following instead 
 +         ​iscsistart \ 
 +         ​-i `cat /​sys/​firmware/​ibft/​initiator/​initiator-name` \ 
 +         ​-t `cat /​sys/​firmware/​ibft/​target0/​target-name` \ 
 +         ​-a `cat /​sys/​firmware/​ibft/​target0/​ip-addr` \ 
 +         ​-u `cat /​sys/​firmware/​ibft/​target0/​chap-name` \ 
 +         ​-w `cat /​sys/​firmware/​ibft/​target0/​chap-secret` \ 
 +         ​-g 1 
 +      ​else 
 +         ​iscsistart -i ${iscsi_name} -t ${iscsi_iqn} -a ${iscsi_ip} -u ${iscsi_user} -w ${iscsi_pw} -g 1 
 +      ​fi # end of iscsi firmware check 
 +   fi # end of iscsi env check 
 +fi  # end of initramfs check
 </​code>​ </​code>​
 +Make sure that eth0 is set to manual in /​etc/​network/​interfaces so that Network Manager does not try to reconfigure the interface:
 +<​code>​
 +# This file describes the network interfaces available on your system
 +# and how to activate them. For more information,​ see interfaces(5).
 +
 +# The loopback network interface
 +auto lo
 +iface lo inet loopback
 +
 +# The primary network interface
 +#auto eth0
 +iface eth0 inet manual
 +iface eth1 inet manual
 +iface eth2 inet manual
 +</​code>​
 +
  
 Then do these commands at the terminal: Then do these commands at the terminal:
Line 99: Line 193:
                                                       # the changes will also take effect even with upgrades                                                       # the changes will also take effect even with upgrades
 </​code>​ </​code>​
 +You are now finished with editing the client. Shutdown the client now.
  
-== OptionalDo the following if you want your eth0 interface ​to have the same name even if the image is booted on different machines ==+==== Last stepTransfer ​the image to the server ==== 
 + 
 +You could just copy the image as is, but it is even smarter to make a sparse file.  That way only actual data is copied and not the empty sectors. ​ You can do this under linux with the cp command:
 <​code>​ <​code>​
-sudo -s                                                   # Change to root access +cp --sparse=always disk.img /media/server-data/disk-images/disk.img
-rm /​etc/​udev/​rules.d/​70-persistent-net.rules              # Get rid of this rule so that your current eth0 interface doesn'​t get changed +
-rm /lib/udev/rules.d/75-persistent-net-generator.rules    # This re-creates the above, so get rid of it too+
 </​code>​ </​code>​
  
-Note: I don't know if the above steps are the best way to make eth0 name staticbut this is what works for me. +If you installed ​to a physical machineboot up the machine with a live linux cd, become root and do this command: 
- +<​code>​ 
-You are now finished with editing the client. Shutdown the client now.+cp --sparse=always /dev/sda /​media/​server-data/​disk-images/​disk.img 
 +</​code>​
  
 ===== Server side setup (target): ===== ===== Server side setup (target): =====
Line 143: Line 239:
 That's it! Start your server by running "sudo /​etc/​init.d/​iscsitarget restart"​ and boot your pxe client and see what happens. That's it! Start your server by running "sudo /​etc/​init.d/​iscsitarget restart"​ and boot your pxe client and see what happens.
  
- --- //Quinn Plattel 2010/09/22 10:09//+===== BTRFS workaround ===== 
 +In order to work around the kernel oops when iscsi image files are residing on a btrfs file system, change the /​etc/​ietf.conf file as follows: 
 +<​code>​ 
 +Target iqn.2010-09.org.test:​diskimg 
 +        IncomingUser user password 
 +        OutgoingUser 
 +        Lun 0 Path=/​dev/​loop0,​IOMode=wb,​Type=blockio 
 +</​code>​ 
 +...and create a loop device that points to the image: 
 +<​code>​ 
 +losetup /dev/loop0 /​mnt/​disk-images/​disk.img 
 +</​code>​ 
 +Remember to restart the iscsitarget service. 
 + 
 +===== Random Notes ===== 
 + 
 +    * If you don't install any proprietary video drivers, then what you got here is an image that will boot from either iSCSI, USB, or any internal/​external disk on any machine. 
 +    * Since Ubuntu is Debian based, these steps should work with Debian too but I haven'​t tried it myself 
 +    * If you can't use the ibft interface or need to load the kernel and initrd from another source than iscsi, then you can pass the following kernel command line arguments to get it to connect to iscsi: 
 +<​code>​ 
 +      iscsi_iqn= ​ The iscsi qualifier name 
 +      iscsi_ip= ​  The target server'​s ip address 
 +      iscsi_user= The username to login to the target server 
 +      iscsi_pw= ​  The password to login to the target server 
 +</​code>​ 
 +    * pcmcia support is now complete. ​ All linux supported pcmcia and cardbus network cards should work 
 +    * You cannot create sparse images if you copy to a windows or samba network share, use nfs/ssh/nc (netcat) instead. ​ Here is an example with nc (netcat): 
 + 
 +Client side: 
 +<​code>​ 
 +cat /dev/sda | nc -l -p 1234 
 +</​code>​ 
 + 
 +Server side: 
 +<​code>​ 
 +nc <​client-ip>​ 1234 | cp --sparse=always /dev/stdin disk.img 
 +</​code>​ 
 + 
 + 
 + --- //Quinn Plattel 2010/10/14/
 + 
 +    * This method disables iscsid. I have detected (probably the same) problem with it under Maverick (2.6.35 kernel), but not under Lucid (2.6.32 kernel). iscsid fails to reestablish the iscsi session and fails with response status code 0201. The problem is: I need iscsid to attach more iscsi shares... any idea how to solve that issue? 
 + 
 + --- cinquero

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:ubuntu_iscsi2 (generated for current page)