Install & Configure Ubuntu to boot from an iSCSI disk

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.

root@client:~$ update-grub

Now Ubuntu’s boot process is configured to boot over iSCSI, but we still have to setup iPXE to get the boot sequence started.

Part 4: Configuring iPXE (formerly gPXE) for booting an iSCSI disk

8 thoughts on “Install & Configure Ubuntu to boot from an iSCSI disk

  1. Linux_wallabe123

    Thank you very much for this guide!

    I have followed your instructions to the letter and on the last step:
    root@client:~$ update-grub

    I keep getting the following error:
    /usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?).

    Any idea whats causing this?

    I am using ubuntu 10.10 x64 and booting of an intel iBFT nic. When ubuntu attempts to load, it drops to the busy box and says it timed out waiting on the root drive.

    Thanks!

    • heathbar

      Are there any hard drives/USB drives installed in the client machine? If so, when you change to the new system, i.e. when you mount /dev/sda1 on /mnt/newsystem, you need to confirm that /dev/sda1 is your iSCSI disk. You can type “fdisk -l” at the command line to list some basic information about each of the drives you have attached to the computer (Note: this must be run as root/sudo).

      Once you are certain you have located the correct disk, if the /dev directory is still missing, you could manually mount the /dev directory like this:


      root@client:~$ sudo su
      root@client:~$ mkdir /mnt/newsystem
      root@client:~$ mount /dev/sda1 /mnt/newsystem
      root@client:~$ mkdir /mnt/newsystem/dev
      root@client:~$ mount --bind /dev /mnt/newsystem/dev
      root@client:~$ chroot /mnt/newsystem
      root@client:~$ mount -t proc none /proc
      root@client:~$ hostname -F /etc/hostname

      If you haven’t done anything else with your system, you should be able to boot any ubuntu live CD and type these commands. If it’s still not working, I would be interested in seeing the output of the “fdisk -l” command as well as “df -ah”.

      • Andrew

        correction:
        root@client:~$ mount -bind /dev /mnt/newsystem/dev
        should be
        root@client:~$ mount –bind /dev /mnt/newsystem/dev
        also needs
        root@client:~$ mount –bind /sys /mnt/newsystem/sys

        before chrooting.

        Ciao,
        Andrew

      • Fred

        Nice write up.

        If you removed at the bashrc leading “root@client” text it would be easier to cut and paste:

        from:

        root@client:~$ mkdir /mnt/newsystem

        to:

        export newroot=/mnt/newsystem

        mkdir $newroot
        mount /dev/sda1 $newroot
        mkdir $newroot/dev
        chroot $newsystem

  2. Andrew

    Note: verified using 12.04 64bit workstation.

  3. Andrew

    More Notes:
    Having turned off dhcp, (by setting eth0 to manual)
    you now need to add the resolvers manually.

    echo “timeout 2” > /etc/resolv.conf
    echo “search example.com” >> /etc/resolv.conf
    echo “nameserver 192.168.0.110” >> /etc/resolv.conf

  4. John
  5. hugo

    With trusty I also needed to run ‘grub-install /dev/sdf’ (sdf is my iscsi disk during install, the machine is not diskless).

    The module is called iscsi_tcp instead of iscsi in trusty.

Leave a Reply to Andrew Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>