PXE Boot Server

Wow!  Wouldn’t it be nice if you could boot up a diagnostic operating system — Perhaps something as useful Parted Magic — over the network?  With the enormous help of DNSMasq, you can with relative ease!  A big “shout out” to Shawn Powers over at Linux Journal for putting together a great intro to DNSMasq.

We’re going to keep this simple and since we’ll be serving ip addresses,  you may want to separate your network – I’ve found a laptop works brilliantly.  You automatically have 2 interfaces – one (wired) for the PXE network and the other (wireless) for internet access.

The network manager GUI may get in the way of things…
$ sudo apt-get remove network-manager

Change your wired interface to a static IP:
$ sudo /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0

auto wlan0
iface wlan0 inet dhcp
wpa-ssid xxxxx
wpa-psk xxxxx

Let’s turn on packet forwarding from one interface to the other:
https://help.ubuntu.com/community/Internet/ConnectionSharing

$ sudo apt-get install dnsmasq
gets you started on the useful path to booting over the network.

One configuration file?  That’s right! And well commented.  What a relief, because we really don’t need anything fancy when starting out.
/etc/dnsmasq.conf is where you’ll find the options to set up your PXE boot config .

To specify an interface for DHCP, uncomment:
interface=eth0     # change to your interface if necessary

To turn on the DHCP server, uncomment:
dhcp-range=192.168.1.70,192.168.1.100,12h     # You may want to use different IPs #

** Uncomment the boot filename **
dhcp-boot=pxelinux.0

DNSMasq also gives you options for menus!
“Boot from local disk”
“Install Linux”

To enable the tftp server, uncomment:
enable-tftp

** Remember to tell DNSMasq where your pxelinux.0 file is **
tftp-root=/var/lib/tftpboot

RECAP
Basically, you’re doing this…
interface=eth0
dhcp-range=192.168.101.100,192.168.101.200,12h
dhcp-boot=pxelinux.0
enable-tftp
tftp-root=/var/lib/tftpboot/
dhcp-option=3,192.168.101.1  # To set the gateway
dhcp-option=6,8.8.8.8,8.8.4.4  # To set DNS servers

Restart DNSMasq
$ sudo service dnsmasq restart

EASY!!!  Now transfer your PXE files into /var/lib/tftpboot
$ sudo mkdir /var/lib/tftpboot

Let’s start with pxelinux.0
$ sudo cp /usr/lib/syslinux/pxelinux.0 /var/lib/tftpboot/

# ** Note:  you need to copy ldlinux.c32 from an Ubuntu iso (/install/netboot/ubuntu-installer/amd64/boot-screens) to /var/lib/tftpboot

For Parted Magic, create a directory for it:
$ sudo mkdir /var/lib/tftpboot/pmagic

Put the following files into your pmagic directory:
bzImage
bzImage64
files.cgz
initrd64.img
initrd.img

Create a pxelinux.cfg directory:
$ sudo mkdir /var/lib/tftpboot/pxelinux.cfg

In your pxelinux.cfg directory, create a file called “default” and enter similar text:
DEFAULT pmagic32

LABEL pmagic32
LINUX pmagic/bzImage
INITRD pmagic/initrd.img,pmagic/files.cgz
APPEND edd=on vga=normal

LABEL pmagic64
LINUX pmagic/bzImage64
INITRD pmagic/initrd64.img,pmagic/files.cgz
APPEND edd=on vga=normal

Allright ! or Allright ???
You may need to modify your settings to get this working properly.

When you’re ready to take this to the next level…
http://cdimage.ubuntu.com/netboot/

Leave a Reply

Your email address will not be published. Required fields are marked *