Ubuntu Live CD/Network Boot

April 29, 2009

Live CDs are great. In particular, they’re a great way to try out software, knowing that the chances of damaging the host system are minimal and you can throw away the entire system if you want to.

Sometimes you want to use a live CD environment without a CD. CDs are slow, get lost and scratched, and require a CD drive. If you’re going to use live environments a lot, you’d probably prefer to boot them over the network from a machine with a hard disk and a cache.

Luckily, Ubuntu’s live CD includes all the necessary support to do this easily, if you know how to use it. Unfortunately, it’s not really documented as far as I can tell. Please correct me if I’m wrong about this.

I managed to make the live CD boot over the network on a PXE client using the following steps.

  • set your DHCP server up to hand off to a TFTP server. For example, add the following lines to your subnet definition in /etc/dhcp3/dhcpd.conf:
  • next-server 10.0.156.34;
    filename "pxelinux.0";
    
  • get a copy of pxelinux.0 from the pxelinux package and put it in the tftproot of your TFTP server.
  • copy the casper directory off the CD and put it into your tftproot as well.
  • get an NFS server on your network to loopback-mount the Desktop ISO (e.g. ubuntu-8.04.2-desktop-i386.iso) and export the mount directory through NFS. Let’s say your NFS server is 1.2.3.4 and the ISO is mounted at /var/nfs/ubuntu/live. Edit /etc/exports on the server and export the mount directory to the world by adding the following line:
  • /var/nfs/ubuntu/live *(ro,all_squash,no_subtree_check)
    
  • put the following section into your tftproot/pxelinux.cfg/default file:
  • DEFAULT live-804
    LABEL live-804
      kernel casper/vmlinuz
      append file=/cdrom/preseed/ubuntu.seed boot=casper initrd=ubuntu/ubuntu-8-04/casper/initrd.gz netboot=nfs nfsroot=1.2.3.4:/var/nfs/ubuntu/live quiet splash --
    
  • test that the PXE client boots into the live CD environment
  • if it doesn’t, remove the “quiet splash” from the end of the “append” line and boot it again, to see where it gets stuck.

I hope this helps someone, and that NFS-booting a live environment will be properly documented (better than this!) one day.

(Also filed on Ubuntu bug 296089.)

Advertisements

6 Responses to “Ubuntu Live CD/Network Boot”

  1. Paul said

    I’m attempting the same thing only using a Windows box as the server. I’m very new at this. I use tftpd32 as the dhcp and tftp server and was wondering if you knew how to configure the pxelinux.cfg/default file so that it would access the host cd-rom.
    Nice tutorial. Thanks

    • chrisw said

      Paul, I think you need an NFS server as well. Why not boot a live CD (on a real machine or a virtual machine) and configure it as your NFS server?

      • paul said

        Thanks for the reply chrisw. I’ve actually kicked windows in the but and I’m currently working on a ubuntu box. I’ve seen a few how to’s and they all mention nfs, but what I would like to do is to boot into the jaunty live cd mode on the client side over pxe (don’t wanna install or share anything), and from what I understand I don’t need nfs for this. Please corrent me if I’m wrong.
        My main issues would actually be to customize pxelinux.cfg/default and to mount the real cd on the server-side.
        I should mention that I’m a total newbie when it comes to linux, but willing to learn 😛
        Again, thanks for your reply

  2. chrisw said

    Hi Paul,

    The problem is that a live CD image has about 600 MB of data on it. I think most of that is in a compressed filesystem. To load it over TFTP using PXE, it would all have to be loaded into the client’s RAM and run from there, because TFTP is a “trivial” protocol and doesn’t support access to parts of files. This is probably why the Ubuntu live CD is designed to mount the compressed filesystem using NFS.

    So I don’t think you could do without an NFS server unless you have heaps of RAM on the clients, AND you’re prepared to hack around majorly with the network boot process, which is a very advanced topic suitable for embedded systems engineers. It’s much much easier just to follow the instructions and set up an NFS server.

    Cheers, Chris.

    • paul said

      Thanks for explaining that, Chris.
      It’s easier to do something when you understand why it is that you’re doing it. 😛
      Cheers! Have a great week!

  3. Reinald said

    Is SquashFS robust for NFS ?

    Thanks for this! I used to boot customized Knoppix via pxelinux and NFS but would migrate to Ubuntu to avoid instable Debian Repos used by Knoppix.

    But Knoppix used compressed_fs were Ubuntu uses squashfs: Diskless Knoppix survived a Serverreboot. Diskless Ubuntu I found serveral times hanging after a day or so with unrecoverable:

    ubuntu kernel: [69366.882128] SQUASHFS error: squashfs_read_data failed to read block 0x28fecab6
    ubuntu kernel: [69366.882135] SQUASHFS error: Unable to read metadata cache entry [28fecab6]
    ubuntu kernel: [69366.882137] SQUASHFS error: Unable to read inode 0xf8c2c10ee

    My sad Impression is that squashfs just can not handle temporary read-errors.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: