NOTE: This is Part 3 in a series on booting Ubuntu from an iSCSI disk. We have previously created an iSCSI disk and connected to it from the Ubuntu Live installation CD. View all of the sections here.
Many of the commands in this post were taken from http://etherboot.org/wiki/sanboot/ubuntu_iscsi.
If you’re following along with the series, you are now on the first screen of the Ubuntu installation wizard and the iSCSI disk has been connected to your system. You can now continue the installation as normal. When you get to the disk selection screen, the iSCSI drive should show up as a normal drive; partition it as you like.
NOTE: After the installation completes, and before you reboot, we have a few more steps to complete. DO NOT REBOOT!
At this point if you rebooted, the boot process would fail with a message indicating that you don’t have a hard drive. If you are not a good listener and decided to reboot anyway, all is not lost. Simply boot to any Ubuntu live disk and follow the instructions in the previous post to connect to the iSCSI drive.
We need to configure the initrd process to connect to the iSCSI disk before it does anything else. In order to do this, we’ll need to mount our newly installed system. So once again open a terminal. Assuming your root file system was installed on iSCSI device /dev/sda1 you would enter
user@client:~$ sudo su root@client:~$ mkdir /mnt/newsystem root@client:~$ mount /dev/sda1 /mnt/newsystem root@client:~$ chroot /mnt/newsystem root@client:~$ mount -t proc none /proc root@client:~$ hostname -F /etc/hostname
Update: Users in the comments indicate you also need to run the following before you run the chroot command. YMMV.root@client:~$ mkdir /mnt/newsystem/dev root@client:~$ mkdir /mnt/newsystem/proc root@client:~$ mkdir /mnt/newsystem/sys root@client:~$ mount --bind /dev /mnt/newsystem/dev root@client:~$ mount -t proc proc /mnt/newsystem/proc root@client:~$ mount -t sysfs sys /mnt/newsystem/sys
Now that we have switched from the live system to the system installed on the iSCSI disk, we need to install some packages.
root@client:~$ apt-get install initramfs-tools open-iscsi sysv-rc-conf
Next, we’ll want to add iSCSI to the list of modules to include in the boot image.
root@client:~$ echo "iscsi" >> /etc/initramfs-tools/modules
Setup the initiator’s unique ID with the following command. You’re welcome to use a different name, however, it must follow the same naming convention as before and cannot be the same as the name of the iSCSI disk itself. If, for some reason, you decide to allow multiple clients to connect to the iSCSI disk, each client computer will need its own unique ID.
root@client:~$ echo "InitiatorName=iqn.2012-03.com.example:xbmc-client1" > /etc/iscsi/initiatorname.iscsi
Touch the indicator file, so that the module is included in the new initrd.
root@client:~$ touch /etc/iscsi/iscsi.initramfs
Finally, we’ll update initramfs.
root@client:~$ update-initramfs -u
There are still a couple of items to clean up before we are ready to reboot. If the networking systems try to renegotiate an IP address, our connection to the iSCSI device will be lost and bad things will happen. So let’s switch the network configuration to manual.
root@client:~$ nano /etc/networking/interfaces
Change this file to read:
auto eth0 iface eth0 inet manual
Lastly we need to update GRUB to pass the iSCSI parameters to the kernel at boot time.
root@client:~$ nano /etc/default/grub
Append the following to GRUB_CMDLINE_LINUX_DEFAULT, substituting the appropriate values.
ip=dhcp ISCSI_INITIATOR=iqn.2012-03.com.example:xbmc-client1 ISCSI_TARGET_NAME=iqn.2012-03.com.example:xbmc-server ISCSI_TARGET_IP=192.168.0.101 ISCSI_TARGET_PORT=3260 ISCSI_USERNAME=<username> ISCSI_PASSWORD=<password>
Update GRUB to lock in the changes.
Now Ubuntu’s boot process is configured to boot over iSCSI, but we still have to setup iPXE to get the boot sequence started.