I've been erasing and reinstalling a few machines lately - some for sale on eBay, some to set them up for friends. And I've finally reached the point where I'm fed up of having to dig out the writable DVDs and download DBAN or Knoppix for the nth time. It's especially irritating when the computer in question doesn't have a DVD drive.

One answer to this is network booting - any PC with an ethernet port these days can usually do it, so all I needed was a network boot server on my LAN at home. I've always been a little nervous of this as it means taking the job of doing DHCP away from the router and doing it myself on a Linux box*, but since I have an always-on Raspberry Pi anyway, I thought I might as well have a go.

There's plenty of information on the internet about this sort of thing, but most of it is out of date or needlessly complicated. I used dnsmasq as my DHCP and TFTP server, and the very latest and greatest pxelinux to boot to. It's worth noting that if you get a new enough version (I compiled myself a 6.03), it has native support for fetching the things to be booted over HTTP (no need to mess around chain-loading something more complicated to do the HTTP bit). This is important, as TFTP is glacially slow to the point of being unusable for multi-megabyte boot images.

Armed with this, you can do the following in dnsmasq.conf:

# Network boot
enable-tftp
tftp-root=/tftpboot
dhcp-boot=lpxelinux.0
# DHCP Option 210 = PXE path prefix (RFC 5071)
dhcp-option-force=210,http://your-network-boot-server/boot/

You need to use Apache or similar to expose the right files under /boot/, of course. Armed with this, you can use paths relative to http://your-network-boot-server/boot/ in the menu configuration for pxelinux and you should see things being booted over HTTP nice and quickly.

I'll finish with a screenshot of a three-year-old laptop displaying my network boot menu:

IMG_20150328_121317

* Yes, if you have a clever enough router you can simply have it announce the network boot server in its DHCP replies and leave it doing DHCP, but when was the last time you saw that option in a consumer-grade router?