Installing Ubuntu with a graphical installer using tftp, dhcpd, and nfs

If you have the facilities, it’s really handy to install Ubuntu using Ubuntu’s nice install environment without having to burn any CDs. Just download the ISO and use it in conjunction with some server stuff and boot any computer off the network to get a fully interactive graphical installation, just as if you’d put in the CD. I also have a gigabit network, so this is a lot faster than using a CD drive.

Without further ado, here is how to do it, in brief. I’m using another Ubuntu machine for the server stuff, other distros may vary:

Install a TFTP server

I use tftpd-hpa (which is the name of the package in the Ubuntu repositories). Make sure it’s all set up OK and is running. I think the configuration defaults to using /var/lib/tftpboot, so that’s the path I’m going to refer to in these instructions.

Download the appropriate netboot.tar.gz

You can find these netboot.tar.gz files on the Ubuntu website. Make sure you get the right one for your architecture and Ubuntu release. Extract it to /var/lib/tftpboot.

Download the Ubuntu Desktop ISO for your architecture.

Make it available via NFS

First, you’re going to need to install NFS if you haven’t already. I think the package is nfs-kernel-server. Then pick somewhere to mount the ISO; I use /srv/ubuntu. If you want to use that too the command is:

sudo mount -o loop /path/to/ubuntu-desktop.iso /srv/ubuntu  

Once you’ve mounted it, you need to make sure the computer you’re going to install Ubuntu onto can reach it. You do this by configuring NFS using the /etc/exports file. My /etc/exports file looks like this:

/srv/ubuntu (ro,insecure,all_squash)  

I know very little about NFS, but that sounds good enough to me. Restart NFS with sudo /etc/init.d/nfs-kernel-server restart. If you have any way of checking it’s available, do so. I personally check by trying to mount nfs://my_server/srv/ubuntu on my Mac.

Grab some files off the ISO

In order to boot into the LiveCD environment, the computer you are netbooting is going to need the kernel off the ISO. If you’ve been following along exactly and are installing Karmic Koala, these files are /srv/ubuntu/casper/vmlinuz and /srv/ubuntu/casper/initrd.lz. Older versions of Ubuntu may use initrd.gz instead, I’m not sure. It doesn’t matter either way. Copy these two files to somewhere in /var/lib/tftpboot. I make a directory called /var/lib/tftpboot/ubuntu-desktop and put them in there.

Add the option to boot this kernel when your computer netboots

In /var/lib/tftpboot/pxelinux.cfg/default, add the following lines (change any paths/server names if yours don’t match). Note I used my server IP address in the ‘nfsroot’ parameter because I’m not sure if this thing can do DNS resolution or not. Also note the line-breaks here for readability:

LABEL live-karmic
kernel ubuntu-desktop/vmlinuz  
append root=/dev/nfs boot=casper netboot=nfs \
  nfsroot=my.server.ip.address:/srv/ubuntu \
  initrd=ubuntu-desktop/initrd.lz quiet splash --

My pxelinux.cfg/default file looks like this. Again, beware of line breaks:

include ubuntu-installer/amd64/boot-screens/menu.cfg  
default ubuntu-installer/amd64/boot-screens/vesamenu.c32  

LABEL live  
kernel ubuntu-desktop/casper/vmlinuz  
append initrd=ubuntu-desktop/casper/initrd.gz boot=casper \
	netboot=nfs nfsroot= --  
prompt 30  
timeout 30

Set up dhcpd to tell the computer to netboot

In your dhcpd configuration file, make a client section for the computer you want to netboot. Add filename=”/pxelinux.0” to this section. The section for the computer I wanted to netboot looked like this:

host ccube {  
  option host-name "";  
  hardware ethernet DE:AD:BE:EF:DE:AD;  
  filename "/pxelinux.0";  

Don’t forget to restart dhcpd.


Set your computer to boot off the network, and watch the Ubuntu LiveCD environment boot before your very eyes!

These are very rough guidelines, not intended to walk you through every baby step involved in netbooting into this environment. I assumed that if you want to do this, you probably already know a fair bit about Linux. There is more information about netbooting available all over the web. Just Google ‘Ubuntu netboot’.

This entry was posted in Blog, Noteworthy. Bookmark the permalink.