IPXE
iPXE is a PXE boot firmware which can be used to PXE boot systems that may not have support. iPXE supersedes the older and no longer actively maintained gPXE boot firmware.
Building
You can build the iPXE image from source pretty easily with the added benefit of being able to customize the image with custom iPXE scripts (see below).
Example
The following script will build iPXE with an embedded script which automatically boots from a HTTP resource.
# git clone git://git.ipxe.org/ipxe.git
# cd git
# cat <<EOF > arch.ipxe
#!ipxe
dhcp
set 209:string cfg/arch.cfg
set 210:string http://linbuild.cs.ucalgary.ca/archlinux/boot/
chain ${210:string}pxelinux.0
EOF
# make bin/ipxe.lkrn EMBED=arch.ipxe
Scripting
For more information, see iPXE's documentation.
Commands
Common commands that will be used are:
| Command | Description |
|---|---|
| dhcp | Obtain IP address via DHCP |
| boot, imgexec, chain | Downloads and boots an executable image |
| initrd, module, imgfetch | Downloads an executable image |
| isset | Checks if a value exists (typically for settings). |
| echo | Prints text to console |
| goto | Go to a specific label |
Flow Control
Create a script label using a colon followed by the label name. Program execution will jump to the label using the goto command.
Use the bash-like || to run a command when something fails or && when something succeeds. Eg:
true && echo Success
false || echo Failure
Notes
Script execution will stop whenever a command fails.
To make the script continue even if a command can error out (such as dhcp, use the || operator at the end of the command which will always make the command succeed. (ie. dhcp || is analogous to dhcp || true).
Example Scripts
#!ipxe
:retry_dhcp
dhcp && isset ${filename} | goto retry_dhcp
# Boot image provided by DHCP
echo Booting from ${filename}
chain {$filename}
Troubleshooting
If you get the following error while building:
[VERSION] bin/version.udionly.kpxe.o
[LD] bin/udionly.kpxe.tmp
--defsym:2: undefined symbol `obj_udionly' referenced in expression
make: *** [bin/udionly.kpxe.tmp] Error 1
rm bin/version.udionly.kpxe.o
Install the syslinux-devel package.