Wednesday 12 May 2010

HOWTO: Install Ubuntu Linux via PXE Boot

Here's how to do a network-based installation of Ubuntu Linux, for machines without CDROM drives.  It is very simple.

You will need a PXE install server (see below) to serve the installation media, and a target machine to install Ubuntu onto.

On the PXE install server:-
  • Unpack the .ISO contents to /usr/local/www/ubuntu
  • Start a webserver on port 80, to serve up /usr/local/www
  • Start a TFTP server, to serve up /usr/local/www/ubuntu/install/netboot
  • Start a DHCP server, to hand out IP addresses, with a boot filename of "pxelinux.0"
On the target machine:-
  • Boot the target machine using PXE. The Ubuntu setup menu should appear.
  • Let the Ubuntu installer run as normal.  Begin installing Ubuntu.
  • When "Choose a mirror of the Ubuntu archive" appears, scroll to the top of the list "Ubuntu archive mirror country", and select "enter information manually".
  • For "Ubuntu archive mirror hostname", enter "" (or the IP address of your PXE install server).
  • For "Ubuntu archive mirror directory", enter "/ubuntu"   (NOTE: the default of "/ubuntu/" does not work.)
That's all there is to it.  It should just work!

HOWTO: Build a PXE Install Server using FreeBSD

You can make a PXE install server very quickly by installing a default configuration of FreeeBSD.   I installed FreeBSD 7.1 as a VMware machine.

Start by installing a minimal version of FreeBSD. Be sure to install the Ports tree when prompted.

Once FreeBSD is installed, we will need three ports: a DHCP server; a web server; and an rsync client.
cd /usr/ports/net/isc-dhcp30-server
make install
cd /usr/ports/www/mathopd
make install
cd /usr/ports/net/rsync
make install   
We will configure these later.  But first, let's unpack the Ubuntu CDROM ISO image (that's what the rsync client was for)…
mdconfig -a -t vnode -u 3 -f /tmp/ubuntu-9.10-i386.iso
mount_cd9660 /dev/md3 /mnt
mkdir /usr/local/www/ubuntu
rsync -avH /mnt/  /usr/local/www/ubuntu
OK, so now you have the entire CDROM tree on your server, at /usr/local/www/ubuntu.

Time to configure some stuff:

ifconfig_em0=" netmask"
!! Change 'ifconfig_em0' to match your LAN card !!
tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /usr/local/www/ubuntu/install/netboot
User daemon
PIDFile /var/mathopd/pid
Control {
    Types {
        text/html { html }
        text/plain { txt }
        image/gif { gif }
        image/jpeg { jpg }
        text/css { css }
        application/octet-stream { * }
    IndexNames { index.html }
Server {
    Virtual {
        Control {
            Alias /
            Location /usr/local/www/ubuntu/
} } }
 ddns-update-style none;
 subnet netmask {
    option broadcast-address;
    option host-name "temporary" ;
    filename "pxelinux.0";
Reboot the PXE install server, and the various daemons should start.  This will conflict with any existing DHCP services on your network, so you probably want to keep it all standalone: just connect the PXE install server to the target machine with an Ethernet crossover cable.

Hope this helps…

Update. Warren Block has written up a nice tutorial on how to set up a FreeBSD PXE server, offering a choice of useful images to boot. See his page at

No comments:

Post a Comment

Spammers: please stop wasting my time. All comments are moderated before publication.