Linux and PHP web application support and development (Bromsgrove, UK)

tel: 0845 0046746

iPXE Network booting for ISO images

Historically we had a ‘normal’ pxe boot server in the office (DHCP server points to a TFTP server and specified a pxelinux file to load) from which we could choose to install various distributions.

The only problem with this is that it was initially limited to the a specific release/version of Debian/Ubuntu (as we’d just copy the bundled install/netboot stuff locally).

Then we added other things into the boot menu – like memtest86 – and then found we could also add in ISO images – so making things a bit easier to setup/maintain – with a simple menu like the below.

In pxelinux.cfg/default :

timeout 120
default LocalBoot
prompt 1

LABEL Memtest
    kernel memtest86

LABEL Debian
    kernel memdisk
    append iso initrd=path/to/some.iso

LABEL LocalBoot
    localboot 0

Where

  • ‘memtest86’ is the file/kernel image from /boot when memtest86 is installed; just make sure you remove a .bin file extension from it if it has one as this will break things.
  • ‘memdisk’ is a binary image taken out of a syslinux download (see bios/memdisk) in the .tar.gz file.

However, the problem with the above is that it’s REALLY slow to load ISO images over TFTP….. Rummaging around on the internet indicates this is a problem with TFTP and the only way to fix this is to use something like iPXE – which allows for much faster booting / loading of ISO images – as it can work over HTTP / iSCSI and other protocols.

While iPXE can be flashed to network cards – this seemed overkill for our environment. It’s easier to ‘chainload’ iPXE from your normal PXE (Network Boot) process.

The only pain in doing this is that iPXE needs an initial configuration – so when it loads, it knows what to do without you having to type things in on the command line. This requires building iPXE from source. Thankfully this is straight forward and takes about 10 seconds.

  1. Download iPXE ( git clone git://git.ipxe.org/ipxe.git )
  2. Create an initial configuration for iPXE – in our case we want to get an IP address via ‘dhcp’ and then display a ‘boot menu’ (located at http://172.30.33.67/netboot/boot.php)…. – see palepurple.ipxe (below).
  3. Run: “make bin/undionly.kpxe EMBED=palepurple.ipxe”
  4. Copy the build file to the TFTP server (bin/undionly.kpxe)
  5. Update DHCP server so it chain loads into undionly.kpxe (see below).

File: palepurple.ipxe (Note, it must start with the #!ipxe bit) :

#!ipxe
echo Some welcome message...
# See http://ipxe.org/scripting for docs on scripting ipxe.
dhcp
chain http://172.30.33.67/netboot/boot.php

And then, within the DHCP server (dhcpd.conf), ensure you have :

...
option tftp-server-name "my.server.name";
next-server 172.30.33.250;
filename "undionly.kpxe"
....

Now when you ‘boot off LAN’, your normal onboard PXE boot thing will talk to your DHCP server, be told it needs to look at the TFTP server on 172.30.33.250 and then load the file ‘undionly.kpxe‘. undionly.kpxe loads, gets itself an IP address via DHCP (as we told it to in palepurple.ipxe above) and then load whatever is specified at http://172.30.33.67/netboot/boot.php (see below).

File: boot.php:

#!ipxe
echo Boot menu
menu Selection
item debian Debian Netboot (7.4)
item fedora Fedora 20

choose os && goto ${os}

# :something is a 'goto' label.
:debian
sanboot http://server/path/to/debian-7.4.0-amd64-netinst.iso

:fedora
sanboot http://server/path/to/Fedora-Live-etc.iso

And that’s it.

, , ,

One thought on “iPXE Network booting for ISO images

Leave a Reply

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