Ubuntu Network Installation with dnsmaq and DD-WRT

The path to get somewhere depends on where you come from, and I often find myself in the situation of having to install Ubuntu without a CD-ROM, on a computer that has buggy or non-supported USB boot. From there, the easy way – I think – is booting from the network, since motherboard usually support PXE.

Booting from the network needs three things:

  • A DHCP server for sending the address of the TFTP server and the pxelinux.cfg file to the DHCP client on the motherboard;
  • A TFTP server setup to serve pxelinux.cfg and the operating system image;
  • The operating system image.

I already have a DHCP server on my home router, and it runs DD-WRT. I had already enabled DNSmasq for DHCP, but I was missing the magic line in Services->Additional DNSMasq Options that tells the motherboard the address of the TFTP server:

dhcp-boot=pxelinux.0,strangebob,192.168.1.123

DD-WRT can run a TFTP server, but that’s a bit complicated. I decided to install dnsmasq on my Ubuntu desktop, because dnsmasq provides, well, DNS, but also a TFTP server.

sudo apt-get install dnsmasq

It also provides a DHCP server, which will be a problem if connected to my home network because it will fight will my DD-WRT DHCP. So I need to disable that and only enable the TFTP server. I modified /etc/dnsmasq.conf to end up with everything commented-out except:

enable-tftp
interface=eth0
tftp-root=/var/ftpd

If fact, it already comes with the DHCP server disabled, because the ‘dhcp-range’ configuration is commented-out by default. I’m specifying the interface because I have more than one network card, and one of them was already busy (used by VirtualBox) and dnsmasq failed to start. Once you’re done with the changes, restart the daemon:

sudo /etc/init.d/dnsmasq restart

You could now try to boot, but the PXE client will complain that it either cannot find a file to boot from, or the mysterious « no boot filename received » message, depending on your firmware. The computer I’m installing has two network cards, and this added a variable to the debugging process, so I plugged both cards in my home switch.

Now this will never work without an operating system to boot. Ubuntu network boot images are available at:

http://cdimage.ubuntu.com/netboot/

Get the right netboot.tar.gz for your target machine, and decompress it in the TFTP server root (defined above in dnsmasq.conf):

sudo tar -xvzf netboot.tar.gz -C /var/ftpd

You should now be able to boot Ubuntu and proceed with the installation.

It didn’t work very well for me. The TFTP client reported it got a response, but then the computer froze. I checked the logs of the TFTP server for clues, and found that the client requested many files, and among them a vesamenu.c32. Knowing that VESA means graphical, my hypothesis was that the crappy video card isn’t supported, so I commented-out the corresponding line from pxelinux.cfg/default and fixed my problem!

As they say, your mileage may vary.

Publicités