Wednesday, 7 November 2007

Installing Ubuntu over the network

So, I upgraded my home machines to Ubuntu 7.10 the other day and everything was just fine and dandy.

But after a couple of days, the wireless network slowed to an absolute crawl on one of them. My first thought was that one of my neighbours had jumped on to the same channel as me again, but testing with another machine showed that this wasn't the case.

No problem, I think, I'll just back up the user data and do a clean install.
Again, this works fine, but I foolishly disconnected the wireless card while it was installing and now I can't get it to work.

Getting tired of this I chuck the CD in again and do another fresh install - with the wireless card in this time.

Unfortunately the CD start's crapping out at this point - after formatting the drive, of course - and refuses to install.

OK, that's it. I'd always intended to set up network booting to make this kind of thing trivial and now I decide I'm going to do it.

A quick google shows several How Tos and away I go.

Of course, it is never quite that straightforward.

My setup is this - I have a server (a hacked Buffalo Linkstation NAS) used to store all my data and running dnsmasq for name resolution.

On the server, I do the following:

Make a directory for the netboot image
(/mnt maps to the data partition on the server)

mkdir /mnt/tftpboot

Get the netboot image from Ubuntu
cd /mnt/tftpboot
wget http://archive.ubuntu.com/ubuntu/dists/gutsy/main/ _           installer-i386/current/images/netboot/netboot.tar.gz
*The above line has been split to make it readable
tar -xvzf netboot.tar.gz -C /mnt/tftpboot/
chown -R nobody:nogroup /mnt/tftpboot

Install packages
apt-get install tftpd-hpa tftp-hpa xinetd

Configure TFTP server
(Note that the server_args points to the folder containing the netboot image downloaded previously)
pico /etc/xinetd.d/tftp
service tftp
{
     disable= no

socket_type= dgram

wait= yes

user= root

server= /usr/sbin/in.tftpd

server_args= -v -s /mnt/tftpboot

only_from= _local_network_/24

interface= _server_ip_address_
}

Apply changes
resart xinetd
killall -HUP xinetd

Configure DHCP
pico /etc/dnsmasq.conf
dhcp-range=_range_start_,_range_end_,12h
dhcp-boot=pxelinux.0
*Note: we don't need the full path here, just relative to the _server_args_ path above.

Apply Changes
/etc/init.d/dnsmasq restart


And that is it!

On the server, run
tail -f /var/log/syslog

and boot a machine from the network. You should see it getting an address and then downloading the necessary files.

Works lovely, no need for CDs, and much quicker too!