What is gPXE - now it s iPXE

A better PXE subsystem

From the begening

Etherboot

First, we had etherboot, very old project, and very useful. You can take some informations from this site http://etherboot.org

Oh, miracle this guy want to talk about another boot system based upon PXE, it's gPXE, from a GsOC, it was a very interesting conference. after i saw it (few hours after) i want to create a setup for testing, and it was so simple and useful that i scratched my old setup and only use the new one.

gPXE

Download it from source, git and compile it.

cd /data/Tools

git clone git://git.etherboot.org/scm/gpxe.git
git pull
cd gpxe/src
make bin/undionly.kpxe

But you can also create an option rom or an iso file for booting your system. For doing this, you must change kpxe with rom or iso.

The undionly is the way to boot generic interface (Universal Network Device Interface)

iPXE

Same as gPXE, but there's no dev on gPXE since august 2010, and a new project starts known as iPXE.

all what i written on gPXE is valid for iPXE, the git clone is just not the same.

cd /data/Tools
git clone git://git.ipxe.org/ipxe.git
git pull
cd ipxe/src
make bin/undionly.kpxe

(g|i)PXE with serial console

Same as before but we must uncomment some parameters in the sources code

cd /data/Tool/src/config

sed -i 's=^//#define CONSOLE_PCBIOS=#define CONSOLE_PCBIOS=' console.h

sed -i 's=^//#define CONSOLE_SERIAL=#define CONSOLE_SERIAL=' console.h

cd ../..
make bin/undionly.kpxe

Yes, it s juste to uncomment the serial entry and the "bios" output.

Syslinux V3 subsystem

download syslinux and checkout the V3.86.

cd /data/Tools
git clone git://git.kernel.org/pub/scm/boot/syslinux/syslinux.git
git describe                             # answer something like syslinux-4.06
git checkout syslinux-3.86
git describe                             # answer something like syslinux-3.86
make install INSTALLROOT=/data/Boot/Syslinux

The Dhcp config

What we want to do

We have a new computer, but with a clean hard drive, no OS on it. We can't boot and use this computer.

What we want to do, many thing like:

  • Boot a live operating system (Windows or Linux).
  • Start some system check (memtest86, hdt).
  • Begin a system installation.

We can do this for real or virtual environment.

What we add in config file

Add the boot file.

option bootfile-name "/gpxe/undionly.kpxe";

with this, we risk to download and execute the same file again and again. For breaking the infinite loops we can add this.

option space gpxe;
option gpxe-encap-opts code 175 = encapsulate gpxe;
option gpxe.bus-id code 177 = string;

And we use gpxe.bus-id for checking if we already download the gPXE boot file. Another way is to use this code.

if exists user-class and option user-class = "gPXE" {
      filename "http://bootserver.my.zone.tld/pxelinux.cfg/gpxe.php";
} else {
      filename "/gpxe/undionly.kpxe";
}

A web server for the boot system !!

Why we want a web server

We want, no, we need to leave the tftp subsystem for booting the whole environment. In fact if we want to boot a very large file (more than 200Mo). The tftp is only use for sending the gPXE boot system, then the computer starts the gpxe subsystem, we can start to download a kernel or a disk for booting an operating system.

I think http is the better for doing this, but we can also use AoE, Iscsi.

We have a GUI and a CLI

The gui is a curses config system.

we also have cli.

Boot from http

for this, we need a file (gpxe.php), who can send the boot command to gPXE, so if we get the url http://bootserver.my.zone.tld/pxelinux.cfg/gpxe.php with a web browser like curl, we have some gPXE script, or boot chain to a syslinux subsystem.

You must use the syslinux V3 not the syslinux V4.

gPXE Script

For booting a disk image

user@host:~/> curl http://bootserver.my.zone.tld/pxelinux.cfg/gpxe.php
#!gPXE
kernel http://bootserver.my.zone.tld/pxelinux.cfg/bin/memdisk
initrd http://bootserver.my.zone.tld/image/freedos.img harddisk=1

Syslinux config file

the same with syslinux subsystem for memtest or hdt.

user@host:~/> curl http://bootserver.my.zone.tld/pxelinux.cfg/gpxe.php
DEFAULT menu.c32
PROMPT 0
MENU WIDTH 80
MENU MARGIN 10
MENU PASSWORDMARGIN 3
MENU ROWS 12
MENU TABMSGROW 18
MENU CMDLINEROW 18
MENU ENDROW 24
MENU PASSWORDROW 11
MENU TIMEOUTROW 20
# Return to Main Menu
 LABEL Main
   MENU DEFAULT
   MENU LABEL ^Main Menu
   KERNEL menu.c32
   APPEND default
MENU TITLE Main Menu
#
# Menus
#
# gPXE
LABEL Support
  MENU LABEL ^1 - Support
  KERNEL menu.c32
  APPEND support.conf
...
user@host:~/> curl http://bootserver.my.zone.tld/pxelinux.cfg/support.conf
...
LABEL Hardware Dectection Tool
  MENU LABEL ^Hardware Dectection Tool
  KERNEL bin/hdt.c32
  APPEND modules=bin/modules.pcimap pciids=bin/pci.ids
LABEL Memtest
  MENU LABEL Memory tester
  KERNEL bin/memtest
#
...

The second solution is very interesting because we can use menu, but tje first is interesting because it s non interactive. For interactive use, the syslinux subsystem is better, but for unattended install the first one is better.

It will be very interesting if we can switch dynamically from gPXE script to syslinux config file, and the php script can do this. if we have a php setup who can check in a database some config, this php script can choose how to boot.