PXE Netinstall of Ubuntu without CD or Floppy HOWTO


DO you want to install Ubuntu Linux on a machine without a CD-ROM drive, but that is enabled for network boot (PXE boot)? PXE boot is a "preboot execution environment" and is a system for booting diskless workstations from DHCP enabled network. It can be used to install Linux on computers without CD drives. It is also sometimes described as "boot from ethernet card". If that describes what you want, then read on.

This document details what I did to make PXE install of Ubuntu Linux actually work. That was for my Fujitsu LifeBook B2620 laptop. When doing so, I consulted several webpages that I found in google. All of them were actually wrong and did not go into enough detail to explain what various operations meant. This page is meant to rectify that. I will explain what I did, how I did it, and how to fix it.

My Setup

I wanted to install Ubuntu in a Fujitsu Lifebook laptop. However, I had Fedora for a server. That was not a problem.

PXE works as follows: Upon boot, if PXE booting is selected, The computer's BIOS obtains IP information via DHCP, finds out the name of server to serve boot files. Then it gets the boot files via TFTP (a simplified version of FTP used for booting), and runs them. Your goal is to implement DHCP, and to provide boot files that enable you to perform netinstall of Ubuntu.

Step 1 -- install dhcpd and tftpd. This step depends on whether you run Fedora or Ubuntu. For fedora, type

    yum -y install dhcp tftp-server
. For Ubuntu, you would type
    sudo aptitude install dhcp3-server tftpd

You need to edit /etc/dhcpd.conf and set it up correctly. My own dhcpd.conf is here. The 10.56.35.* IP addresses refer to my home's private subnet. Your settings may be different. What you need to make sure, is that your settings leave the client machine (the one you will be setting up) to access the Internet for netinstall. Netinstall cannot work without "net". (duh). Expect to spend at least 1/2 hour figuring out good DHCP settings for your network. This is more complicated if there is another DHCP server on your network, as it often is the case. Try to avoid giving up in frustration, as this is a useful exercise. (if you feel that I am wrongly assuming that you do not know this aspect of Linux system administration, I apologize).

Many webpages and manpages are written about how to configure IP range, etc. The important (from your standpoint) lines are as follows. next-server gives an IP address of the server that serves TFTP requests for boot files.

In my case, is the private IP address of my home server. It makes sense to give the same IP address as your server. Another directive that is crucial is:
    filename "pxelinux.0";
Also make sure that you place these directives in the right location in the file.

Fun part -- setting up TFTPD

Here's where I found out that most pages with instructions on this topic are wrong. Boot files should be placed in a precise location and if you mess it up, your stuff may not work and you would not get much of a diagnostic.

Under Fedora, TFTP directory is under /tftpboot. Under Ubuntu, it is under /var/lib/tftpboot. You need to copy files from your install CD. You can do it in two ways.

First is to grab this tar file, place it under tftpboot directory and untar:

    cd /tftpboot
    wget http://igor.chudov.com/projects/PXE-Netinstall-Of-Ubuntu/untar-in-tftpboot.ubuntu.gutsy.tar.gz
    tar xvfz untar-in-tftpboot.ubuntu.gutsy.tar.gz
After untarring, your TFTP files would be set up. This is for i386 alternate install (text install) CD.

The second approach is to get a filesystem tree of your ubuntu and move some files. Suppose that you have ubuntu ISO file under /tmp/ubuntu-7.10-alternate-i386.iso. You need to do a "loop mount" by saying (perhaps as root)

    mkdir /mnt/ubuntu-cd
    mount -o loop,ro /tmp/ubuntu-7.10-alternate-i386.iso /mnt/ubuntu-cd
    ls -l /mnt/ubuntu-cd
This ensures that Ubuntu CD has been mounted as a loop filesystem. If you have a CD instead of an ISO file, you should mount that CD.
    mkdir /mnt/ubuntu-cd
    mount /dev/cdrom /mnt/ubuntu-cd
    ls -l /mnt/ubuntu-cd 
Then do ls -l /mnt/ubuntu-cd to see if it was mounted. Then you need to copy the netinstall files from there to tftpboot directory:
    cp -r  /mnt/ubuntu-cd/install/netboot/ubuntu-installer/i386/* /tftpboot 
    cp -r  /mnt/ubuntu-cd/install/netboot/ubuntu-installer /tftpboot 

New!!! Script to do all of the above

link to a script that would do all of the above. You need to edit it and set up proper DHCP settings. This script does not touch default system wide config files.

Starting tftpd

I like to start it with:

    tftpd -s /tftpboot -v -v -l
This means, chroot to /tftpboot, be more verbose in logging, and listen standalone on the port. You can check /var/log/messages or /var/log/syslog for tftpd messages by saying:
    tail -f /var/log/messages /var/log/syslog &
That starts tail in background, so you can see error messages. Note that if your xinetd is configured to start tftpd, then the above will not work, but xinetd would then be starting tftpd automatically.


Now it is time to boot your client and make sure that it is connected to the network, and that PXE boot (ehternet boot) is selected as the boot method. Usually you do this by pressing something like F12 during BIOS self check. Keep an eye on the output of tail (see above) as you are doing this to see if any errors occur on the server.

(Click on the thumbnail images to enlarge)