A Quick Guide to iPXE

iPXE is great. I use it loads at home & work. It lets you boot your computer over the network.
  • No more burning CDs.
  • No more writing to USB sticks to find they don't boot, and waiting ages for them to finish writing.
  • No more scrabbling around for USB CD drives
  • At work, no more wondering how you're going to install an OS on that EX-zone rated computer that only has one USB1.0 port (I've had to deal with these quite a lot now!)
So, maybe your thinking, "Oh yeah, I tried PXE boot once, it was fiddly because you have to set up a DHCP server, TFTP server, NFS etc.
No! Read on and I will show you how you need nothing more than a USB stick and a web server. You don't even have to mess with the DHCP server which most of us now have on their home router.....

No More DHCP

I wanted to leave my home router alone, it serves the IP addresses out, but I don't have much control over the rest of DHCP - I can't change it to tell the client computers where to PXE boot from (i.e. with 'Next-server').

But with iPXE it doesn't matter!
Let's assume our web-browser is at 192.168.0.4.
We can make a USB stick or CD to boot iPXE and point it to the web browser.

From the iPXE Rom-O-Matic website, choose USB or CD ISO image, and copy the following script into the box:
1  #!ipxe
2  echo ===== My iPXE Script =====
3  echo MAC address is ${net0/mac}
4  prompt --key 0x02 --timeout 2000 Press Ctrl-B for the iPXE command line... && shell ||
5  dhcp
6  chain http://192.168.0.4/ipxe/boot.ipxe


Burn/write the image and boot it. (That's the last boot media you'll need!)

Set up the webserver.

Ok, so now the iPXE is booting and pointing to the webserver, we need to make a menu, so copy this into /ipxe/boot.ipxe on the web server...
1  #!ipxe
2  menu Please choose an entry:

3  item clonez2 Clonezilla sanboot
4  item ubuntu Ubuntu Trusty 386
5  item dsl Damn Small Linux
6  item tiny Tiny Core Linux
7  item gparted Gparted Live
8  item clonez Clonezilla Live
9  item msd MS Defender Offline (32-bit)
10  item w8pe64 Windows 8 installation PE
11  item wes7 WES7 installation PE (Needs net use z:)
12  item vmware VMware ESXi 5.5 installer
13  item test Boot current test.php
14  item safeboot McAfee Safeboot 5. boot repair
15  item --gap Advanced Options...
16  item shell Enter iPXE Shell

17  choose os
18  chain http://192.168.0.4/ipxe/${os}.ipxe


You'll also need to copy ldlinux.c32, libcom32.c32, libcom32.c32, libutil.c32, linux.c32 into the same directory as the script. These come from the Syslinux Project
Boot your client again and you'll realise that the menu launches the word after 'item' in the script as the name of the next script to run. I put .ipxe on it to tidy it all up.
Now all we have to do is add the operating systems....

Tiny Core Linux

Here's two ways of booting Tiny Core Linux, which start to demonstrate the power of iPXE.
First you need to get Tiny Core Linux.

Method 1
Copy memdisk from somewhere (ubuntu cd, etc). and copy the iso to the appropriate place on the server...
1  #!ipxe
2  echo Starting TinyCore Linux....
3  dhcp
4  #Boot as iso image...
5  kernel http://192.168.0.4/ipxe/memdisk
6  initrd http://192.168.0.4/ipxe/tinylinux/tiny.iso
7  echo Booting...
8  imgstat
9  boot

This demonstrates the fact that iPXE can copy an entire iso and boot it.
BUT beware! it doesn't work for linux live cds because when the kernel starts up it will re-allocate the memory which stores the iso because it doesn't realise it is not booting off a CD... we'll revisit next.
It does work with small distributions like Tiny Core and FreeDOS.

Method 2
Similar to Method 1...
1  #!ipxe
2  echo Starting TinyCore Linux....
3  dhcp
4  sanboot --no-describe --drive 0x81 http://192.168.0.4/ipxe/tinylinux/tiny.iso
5  echo Booting...
6  imgstat
7  boot
Method 3
Specify the Kernel and init, just like any other bootloader...
1  #!ipxe
2  echo Starting TinyCore Linux....
3  dhcp
4  initrd http://192.168.1.1/ipxe/tinylinux/vmlinuz
5  initrd http://192.168.1.1/ipxe/tinylinux/core.gz
6  echo Booting...
7  imgstat
8  boot

Ubuntu

For larger live CDs you need to set up an NFS server.
You should be able to serve the ISO by HTTP too, but I've not got it working so far.
You can copy the files from the ISO, or I just setup a bind mount, so everything is kept tidy in the iso.
1  #!ipxe
2 echo Starting Ubuntu Trusty i386....
3 dhcp
4 kernel http://192.168.1.1/ipxe/ubuntu/iso/casper/vmlinuz vga=normal boot=casper netboot=nfs nfsroot=192.168.1.1:/var/www/ipxe/ubuntu/iso ip=dhcp --
5 initrd http://192.168.1.1/ipxe/ubuntu/iso/casper/initrd.lz
6 echo Booting...
7 imgstat
8 boot

Windows

I've had mixed results with Windows
You'll find the necessary files on the Windows install CD. Plus the 'wimboot' file which is part of the iPXE package.
Use a recent version of wimboot, I've had problems with the early versions not working.
Windows Embedded Standard 7 works nicely, I haven't managed to get Windows 8 working yet.

Windows Embedded Standard 7
If you need interactive install, or want to copy files from a broken machine then it might be worth putting up a reminder to your users what to type.
You could set up a Samba share for files, but I just use WebDav...
1  #!ipxe
2  echo Starting Ichthys WES7 Install PE environment....
3  echo Continue installation by running setup.exe on SAMBA share:
4  echo TEST: net use z: \\192.168.1.1\TEST
5  dhcp
6  kernel http://192.168.1.1/ipxe/wimboot
7  initrd http://192.168.1.1/ipxe/wes7/bootmgr.exe bootmgr.exe
8  initrd http://192.168.1.1/ipxe/wes7/boot/bcd bcd
9  initrd http://192.168.1.1/ipxe/wes7/boot/boot.sdi boot.sdi
10  initrd http://192.168.1.1/ipxe/wes7/boot/bootfix.bin bootfix.bin
11  initrd http://192.168.1.1/ipxe/wes7/boot/etfsboot.com etfsboot.com
12  initrd http://192.168.1.1/ipxe/wes7/sources/boot.wim boot.wim
13  echo Booting...
14  imgstat
15  boot
Windows 8 Installer
I've not got this working completely. It can boot to a cmd prompt. I'd like to get the installer working and the Microsoft Safety Scanner (aka MS Defender Offline). I'll keep trying, here's where I am so far...
1  #!ipxe
2  echo Starting Windows 8 64bit PE install environment....
3  dhcp
4  kernel http://192.168.1.1/ipxe/wimboot
5  initrd http://192.168.1.1/ipxe/w8pe64/bootmgr.exe bootmgr.exe
6  initrd http://192.168.1.1/ipxe/w8pe64/bcd bcd
7  initrd http://192.168.1.1/ipxe/w8pe64/boot.sdi boot.sdi
8  initrd http://192.168.1.1/ipxe/w8pe64/boot.wim boot.wim
9  echo Booting...
10  imgstat
11  boot

iPXE from PXE

If you are prepared to set up DHCP & TFTP then you can get your client to boot using PXE, then serve an iPXE image which takes you to your iPXE boot screen.
Here's the snippet from the DHCP config which you need, and copy the necessary files to the TFTP directory.

...
1  subnet x.x.x.x netmask x.x.x.x {
2    if exists user-class and options user-class = "iPXE" {
3     filename "http://x.x.x.x/ipxe/menu.php";
4     } else {
5       next-server "pxelinux.0";
6       filename "undionly.kpxe";
7     }
8  }
...
Why bother? Well, if you use a little php (or similar) on the web server, you can serve different images to different MAC addresses, have exotic menus, all sorts of complex combinations which would not be possible using PXE.
Here's an example of how to pass the mac address to the php script from the ipxe script. You can then wrap this in logic to do something according to the mac address...
chain http://192.168.0.1/boot.php?mac=${net0/mac}



Read more at ipxe.org