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 "10.42.42.42" (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:

/etc/rc.conf
ifconfig_em0="10.42.42.42 netmask 255.255.255.0"
!! Change 'ifconfig_em0' to match your LAN card !!
sshd_enable="YES"
inetd_enable="YES"
mathopd_enable="YES"
dhcpd_enable="YES"
/etc/inetd.conf
tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /usr/local/www/ubuntu/install/netboot
/usr/local/etc/mathopd.conf
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 {
        AnyHost
        Control {
            Alias /
            Location /usr/local/www/ubuntu/
} } }
/usr/local/etc/dhcpd.conf
 ddns-update-style none;
 subnet 10.42.42.0 netmask 255.255.255.0 {
    range 10.42.42.100 10.42.42.200;
    option broadcast-address   10.42.42.255;
    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 http://www.wonkity.com/~wblock/docs/html/pxe.html

No comments:

Post a Comment

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