O'Reilly logo

Ubuntu Hacks by Bill Childers, Kyle Rankin, Jonathan Oxer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hack #11. Install from a Network Boot Server

Boot your computer directly off a network server and install Ubuntu without using a CD.

Most modern computers can search the network for a boot server and load the operating system from it without using a local hard disk. This feature is typically used to boot thin clients that may not contain a hard disk at all, but you can also use it as a clever way to start the Ubuntu installation process without needing an install CD. This hack is perfect if you want to install Ubuntu onto a subnotebook with no CD-ROM drive or need to set up a large number of computers for a cluster, lab, or server farm.

Prepare the PXE Boot Server

The first step is to prepare the PXE boot server that will dish up the Ubuntu install image to your client. The easiest way to set this up is with an existing Linux server you have kicking around.

This boot server stores the install image and provides DHCP and TFTP (trivial FTP) services so that computers on the network can find and load the image when they start up. The whole process is triggered by the client connecting to the DHCP server and receiving special instructions telling it to fetch its boot image from the TFTP server instead of from the local hard disk.

Configure DHCP

If you don't already have a DHCP server on your network, start by installing the dhcp-server package on the machine that will be your PXE Boot server:

$ sudo apt-get install dhcp-server

Then edit /etc/dhcp3/dhcpd/dhcpd.conf and add a stanza similar to this:

host pxeinstall {
  hardware ethernet 00:00:00:00:00:00:00;
  filename "pxelinux.0";

Substitute the hardware MAC address of your client's Ethernet card in place of the string of zeros. Strictly speaking, you don't need the hardware line at all, but if you include it, your DHCP server will serve up the boot image only to that specific machine, so you won't need to worry about other random machines picking it up and reinstalling Ubuntu over their existing systems. On the other hand, if you're going to do installs on a lot of machines, you can just leave out that line, and every machine that netboots will be able to run the installer. Once you have updated the config restart the DHCP server:

$ sudo /etc/init.d/dhcpd restart

Configure TFTP

Install a TFTP server:

$ sudo apt-get install tftpd-hpa

Check /etc/inetd.conf and make sure it has a line like this:

tftp   dgram   udp     wait    root  /usr/sbin/in.tftpd /usr/sbin/in.tftpd ⏎
-s /var/lib/tftpboot

Next, restart inetd:

$ sudo /etc/init.d/inetd restart

Now you need to fetch the netboot install image (type the following all on one line):

$ sudo lftp -c "open http://archive.ubuntu.com/ubuntu/dists/dapper/main/installer-i386/current/images/; mirror netboot/"

You will then have a directory called netboot with a number of files in it that need to be placed where the TFTP server can find them. The inetd config line listed earlier shows the path that tftp-hpa uses to store boot images—typically /var/lib/tftpboot—so copy the files there and extract the boot image:

$ sudo cp -a netboot/* /var/lib/tftpboot
$ sudo cd /var/lib/tftpboot
$ sudo tar zxf netboot.tar.gz


You can even use a Windows machine as the boot server by installing a TFTP package such as Tftpd32 and placing the Ubuntu install image into the TFTP server root directory. Tftpd32 also includes a built-in DHCP server that you can use to specify the name of the install image. You can download Tftpd32 from http://tftpd32.jounin.net/.

Setting up a TFTP server is even easier in Mac OS X because tftp is already installed. Just run:

$ sudo mkdir -p /private/tftpboot; /sbin/service \\
                       tftp start

and put your install image in place. You will, however, need to install and configure a DHCP server yourself unless you're running Mac OS X Server.

Boot the Client

In order to start the install process, your client machine needs to be able to perform a PXE network boot. Most modern machines can do this directly with a BIOS setting, although some older machines may need a special netboot floppy image to start the process.

Start up your client machine, use whatever key sequence is necessary to enter the BIOS setup menu, and locate the setting for boot devices. (The key sequence to enter the BIOS is usually something like F2 or Esc.) Set the first boot device to be PXE Boot, Network Boot, or the equivalent; save and exit the BIOS; and let the machine boot up again.


Some computers will display a boot menu when you press F12, so you can choose the boot device on the fly without having to modify your BIOS setting.

This time, your machine should report that it's looking for a DHCP server before it gets to the stage of trying to boot off the hard disk. After being given an IP address, it will report that it's searching for a PXE boot image. A couple of seconds later, you should see the Ubuntu installer splash screen, and after that, the installation can proceed exactly as normal—except that all packages will be fetched directly from an Ubuntu mirror rather than from a local CD-ROM.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required