Skip to content

Getting started with iPXE

MAccadia edited this page Nov 23, 2020 · 1 revision

Getting started with iPXE

iPXE replaces the PXE firmware of your network card and offers a lot of features to extend the possibilities of network boot. Visit http://ipxe.org/ to learn more.

In this tutorial, we'll explore some basic features of iPXE.

Quick start

Using a virtual machine is the easiest way to test and to familiarize with iPXE. Just add the iPXE iso image to the VM's CD/DVD drive and boot from the iso file. In VirtualBox, press F12 and c at the boot screen to boot from the iso.

You can also check the Quick Start guide available at http://ipxe.org/ .

iPXE gives you a command line interface and, most importantly, a way to run scripts. Actually, you've maybe already run a script during the quick start with chain http://boot.ipxe.org/demo/boot.php. Even creating a graphical menu is handled via a script.

All commands are listed here ; documentation about ipxe scripting is here.

Configuring iPXE

Most of iPXE configuration is hard-coded, so any change involves compiling iPXE. As iPXE is relatively small, it doesn't take too much time and effort. All configuration options are documented here.

Prepare to configure

You'll need need to install the following required dependancies in order to build iPXE (for Ubuntu distributions):

sudo apt install git gcc binutils make perl liblzma-dev mtools genisoimage isolinux

and get the iPXE source sode:

  git clone git://git.ipxe.org/ipxe.git
  cd ipxe/src

Keyboard layout

The keyboard layout can be configured in config/console.h. For example, to use a French keyboard, replace:

#define        KEYBOARD_MAP    us

with:

#define        KEYBOARD_MAP    fr

Available keyboard maps are listed here.

Compiling

In order to build the custom iPXE iso, run :

  make bin/ipxe.iso

If all went well, you now have your custom iso named ipxe.iso in the bin folder of the current directory.

Running scripts

There are two ways to make iPXE run scripts : either by embedding the script at build time or by downloading it.

Downloaded script example

To download and run a script from iPXE command line, type:

dhcp

to enable the network and

chain http://boot.ipxe.org/demo/boot.php

to run the script available at http://boot.ipxe.org/demo/boot.php.

This script boots a Linux kernel. Type the command reboot in order to reboot your VM.

Embeded script example

In the iPXE src folder, create a file demo.ipxe with :

#!ipxe
echo Hello world !

and build iPXE iso as before :

make bin/ipxe.iso EMBED=demo.ipxe

Now, you can boot your VM or PC with this iso to see the results.

Chaining scripts

If you don't want to recompile iPXE each time you make a modification to your script, you might want to combine the embeding method with the downloading one.

For example, you can embed this script that downloads another script from http://mywebserver/test.ipxe:

  #!ipxe

  dhcp
  chain http://mywebserver/test.ipxe

Conclusion

We have learnt how to test iPXE and to configure it or make it run different scripts by (re)building it. I hope this tutorial gave you enough understanding of iPXE to dive into the official documentation. For example, you can build your own custom boot menu or run iPXE without a CD using PXE boot (learn more about how to do this here).