PXE network booting
- SYSLINUX tools
- SYSLINUX Menu systems
- Automated network installation with pxeconfig
PXE network booting from Linux servers uses the SYSLINUX and PXELINUX utilities (see also this Wikipedia article). Read the documentation on these pages to get an understanding of the process. The SYSLINUX source code has additional very useful documentation which we have copied here: syslinux.doc and pxelinux.doc.
When a client computer performs a PXE network boot, the Linux DHCP server assigns the client an IP-address and further information including a TFTP-server address (DHCP next-server option) and a boot image file name pxelinux.0 (DHCP filename option). The client retrieves the file pxelinux.0 from the TFTP server and executes it.
The pxelinux.0 PXELINUX boot image then attempts to download configurations files from the TFTP server in the boot process explained here. To summarize: The PXE/network client will use TFTP to download a PXELINUX configuration file from the server's /tftpboot/pxelinux.cfg/ directory whose name is usually either:
- the client's hexadecimally encoded IP-address (such as 0A018219), or
- the file named default.
With newer versions of SYSLINUX it is also possible to PXE-boot into the SYSLINUX menu systems where many booting options can be configured. This is a very flexible way to boot, for example, diskette images with BIOS upgrades, hardware testers, or SystemImager installation, etc.
Although your Linux machine may already have some of the SYSLINUX tools installed, it is recommended that you get the latest version of SYSLINUX.
Unpack the tar-ball and copy the following SYSLINUX files to the /tftpboot directory on the DHCP/TFTP server:
tar xzvf syslinux-4.02.tar.gz cd syslinux-4.02 cp core/pxelinux.0 memdisk/memdisk com32/modules/chain.c32 com32/menu/menu.c32 /tftpboot/
(version 4.02 is used in this example). Additional com32/*/*.c32 modules might be needed if further features from SYSLINUX will be used.
For the older SYSLINUX version 3.x the locations of files differ a bit, so do:
tar xzvf syslinux-3.51.tar.gz cd syslinux-3.51 cp pxelinux.0 memdisk/memdisk com32/modules/*.c32 /tftpboot/
If for some reason you must rebuild SYSLINUX, first verify that you have the nasm package installed:
rpm -q nasm
Then build SYSLINUX in the top-level directory by doing simply make. See also the file distrib.doc for further details.
You must also create a default PXE boot file /tftpboot/pxelinux.cfg/default instructing the node how to boot in case there is no hexadecimally encoded IP-address file. Probably the most sensible default boot method is local hard disk which is configured as follows:
We assume that you have installed the SYSLINUX tools as shown above, in particular the chain.c32 tool. Then create the file named default containing these lines:
default harddisk label harddisk kernel chain.c32 append hd0
For comparison, in many places you will find the following recipe for the default file:
default harddisk label harddisk localboot 0
This recipe can be error-prone and actually means boot from the next device in the BIOS boot order, rather than booting from the hard disk as you would be led to believe. For more information read this article from the SYSLINUX mailing list (look at the bottom of the article).
For a solution, see Linux and Windows deployment:
- This covers the setup and deployment of a PXE boot solution consisting of 2 pxe servers and one dhcp server. The 2 PXE servers are linux and windows - the former running pxelinux and tftp and the latter one running WDS (Windows Deployment Services), with a linux server providing DHCP services.
- As it turns out, thanks to the lesser-known pxechain utility, it is possible to seamlessly jump from one PXE host to another. With a few tweaks to your WDS server, you can continue to use it for Windows OS installs and bounce over to a Linux host for Linux, ESXi, or rescue-CD purposes.
With newer versions of SYSLINUX it is possible to PXE-boot into the SYSLINUX menu systems where many booting options can be configured. This is a very flexible way to boot, for example, diskette images with BIOS upgrades, hardware testers, or SystemImager installation, etc.
Please consult the README.menu from the SYSLINUX source.
One must first install SYSLINUX files to /tftpboot on the DHCP/TFTP server as shown in Installing the SYSLINUX tools.
Secondly, for each client machine that should use the SYSLINUX menu systems a hexadecimally encoded IP-address file must be created in /tftpboot/pxelinux.cfg/, pointing to the menu configuration file. This can conveniently be done with the pxeconfig command discussed below.
A simple default.menu SYSLINUX menu file in /tftpboot/pxelinux.cfg/ is:
DEFAULT menu.c32 PROMPT 0 MENU TITLE Menu from TFTP server label harddisk menu label Boot from local harddisk kernel chain.c32 append hd0 label memtest86 menu label Memtest86 memory tester kernel memtest86 label BIOS menu label BIOS upgrade ibm_fw_bios_c0e132a kernel memdisk append initrd=ibm_fw_bios_c0e132a_anyos_i386.img label CentOS-4.4-i386 menu label Installation of CentOS-4.4-i386, no kickstart kernel CentOS-4.4/vmlinuz append load_ramdisk=1 initrd=CentOS-4.4/initrd.img network
This configuration will display a menu with 4 items, each performing a different task as described in the menu label lines.
SYSLINUX version 4 contains a HDT - Hardware Detection Tool. HDT (stands for Hardware Detection Tool) is a Syslinux com32 module that displays low-level information for any x86 compatible system. It provides both a command line interface and a semi-graphical menu mode for browsing.
To enable HDT install the hdt.c32 module from the SYSLINUX source:
cd syslinux-4.02 cp com32/hdt/hdt.c32 /tftpboot/
Then add a PXE menu section to the default.menu file:
label hdt menu label HDT - Hardware Detection Tool COM32 hdt.c32
While you could boot the Ultimate Boot CD directly, you could also extract the utilities from the CD and put them into your PXE menus. This is easier than downloading the tools yourself from very many different places.
You can copy the Ultimate Boot CD tools from the CD, or from the ISO image if you mount it first onto /mnt:
root# mount -o loop /some-path/ubcd503.iso /mnt
You can very simply enable the complete Ultimate Boot CD tools in a PXE environment by copying the entire CD structure to /tftpboot/ on your TFTP server:
root# cp -rp /mnt/ubcd /tftpboot/
and add this configuration to the SYSLINUX menu file:
label UBCMenu menu label Ultimate Boot CD menu kernel menu.c32 append ubcd/menus/syslinux/main.cfg
Alternatively, with SYSLINUX version 4 and above you can PXE-boot the 300MB UBC ISO-image directly (loading the TFTP server much more). The loading of ISO CD images with SYSLINUX is described in http://syslinux.zytor.com/wiki/index.php/MEMDISK#ISO_images. The SYSLINUX menu file could have a section like:
label UBCMenu-iso menu label Ultimate Boot CD (300 MB ISO file) linux memdisk initrd ubcd503.iso append iso
The command line prompt supports the following keystrokes (see syslinux.doc):
<Enter> boot specified command line <BackSpace> erase one character <Ctrl-U> erase the whole line <Ctrl-V> display the current SYSLINUX version <Ctrl-W> erase one word <Ctrl-X> force text mode <F1>..<F10> help screens (if configured) <Ctrl-F><digit> equivalent to F1..F10 <Ctrl-C> interrupt boot in progress <Esc> interrupt boot in progress
You can automate the PXE/network booting process completely using the pxeconfig toolkit written by Bas van der Vlies. The pxeconfig toolkit manipulates configuration files in the server's /tftpboot/pxelinux.cfg/ directory, namely the client's hexadecimally encoded IP-address, for example:
0A018219 => 10.1.130.25
Download the pxeconfig toolkit and read the pxeconfig installation instructions.
To use pxeconfig you should create any number of PXELINUX configuration files named default.<something> which contain different PXELINUX commands that perform the desired actions, for example, BIOS updates, firmware updates, hardware diagnostics, or network installation.
Use the pxeconfig command to configure those client nodes that you wish to install (the remaining nodes will simply boot from their hard disk). An example is:
# pxeconfig n003 Which pxe config file must we use: ? 1 : default.memdisk_ibm_s50_bios 2 : default.memdisk_326m_bmc_fw118 3 : default.memtest86 4 : default.node_install.s50 5 : default.harddisk.BAK 6 : default.node_install.thul 7 : default.node_install.ibm326 Select a number: 7
The pxeconfig command creates soft-links in the /tftpboot/pxelinux.cfg/ directory named as the hexadecimally encoded IP-address of the clients, and these links will point to one of the files default.*. As designed, the PXE network booting process will download the file given by the hexadecimal IP-address, and hence network installation of the node will take place.
To list the soft links created, use the pxeconfig tool hexls and look for the IP-addresses and/or hostnames. A sample output is:
# hexls /tftpboot/pxelinux.cfg/ | sort 0A018103 => 10.1.129.3 => n003.dcsc.fysik.dtu.dk -> default.node_install.ibm326 0A028248 => 10.2.130.72 => t072.dcsc.fysik.dtu.dk -> default.node_install.s50 0A02826B => 10.2.130.107 => t107.dcsc.fysik.dtu.dk -> default.node_install.s50 0A02833D => 10.2.131.61 => u061.dcsc.fysik.dtu.dk -> default.node_install.s50 default default.harddisk default.harddisk.BAK default.memdisk_326m_bmc_fw118 default.memdisk_ibm_s50_bios default.memtest86 default.node_install.ibm326 default.node_install.s50 default.node_install.thul
The pxeconfigd daemon will remove the hexadecimally encoded IP-address soft-link on the server when contacted by the client node. In order for this to happen, you must go to the image server's /var/lib/systemimager/scripts/post-install directory and create the file 30all.pxeconfig:
#!/bin/sh # To be used with the pxeconfig tool. # Remove the <hex_ipaddr> file from the pxelinux.cfg directory so the client will boot from disk. # Get pxeconfig from ftp://ftp.sara.nl/pub/outgoing/pxeconfig.tar.gz # Get the Systemimager variables . /tmp/post-install/variables.txt telnet $IMAGESERVER 6611 sleep 1 exit 0
When this script is executed on the node by SystemImager in the post-install phase, the telnet command connects to the pxeconfigd daemon on the image server, and this daemon will remove the hexadecimally encoded IP-address soft-link in /tftpboot/pxelinux.cfg/ corresponding to the client IP-address which did the telnet connection.