You have always been able to build iPXE with a custom script by compiling it to the ipxe binary like this:
cd /path/to/ipxe/source make EMBED=myscript.ipxe
However recently Micheal Brown added a great new feature to iPXE, you can now load a script as an initrd. Being able to load a script dynamically opens up some interesting new possibilities and certainly makes updating my utility memory stick much easier.
I’ve made a really basic 16MB bootable disk image, for people who just want to start out simply with the iPXE scripting. The image has the latest version of iPXE and syslinux installed and ready to go. Once you have written it to a memory stick with dd or winimage there is a simple ipxe script called script.ipxe that you can edit.
I use a more slightly more complex setup that allows me to hook iPXE into my general utility memory stick that boots with syslinux. I have added iPXE and so far only a script that allows me to boot over the network from an iSCSI disk with a Ubuntu system on. I’ve broken the syslinux config up on the memory stick to make it easier to read and maintain.
This line to added to my general syslinux menu shows the iPXE menu
include ipxe/ipxe.cfg
In the syslinux/ipxe folder of my memory stick there are four files:
ipxe.krn – this is the actual iPXE binary
ipxe.cfg – this is a simple syslinux config fragment that I use the include directive in the main syslinux menu to load.
label ipxe menu label iPXE loading a script kernel ipxe/ipxe.krn append initrd=ipxe/iscsi.pxe
iscsi.pxe – a basic iSCSI boot script for ipxe. This is just an example, there is much more possible with ipxe scripting.
#!ipxe dhcp set keep-san 1 sanboot iscsi:<iscsi disk id>
update-ipxe.sh – a quick bash script to update ipxe to the latest git version as well as compiling and copying it to the right place.
#!/bin/sh pwd=$(pwd) src=/usr/src/git/ipxe/src cd $src git pull make bin/ipxe.lkrn cp $src/bin/ipxe.lkrn $pwd/ipxe.krn
I have rolled up a tarball of the files and uploaded it here as well: iPXE files for syslinux