PXE remote boot for your home/work lab

PXE is a well known and widely used in some enviroments. I’m quite often playing with some servers, testing, installing various things, reflashing firmwares etc. Usually that was done with PLD RescueCD on a CDRW medium, (Free)DOS images/isos etc. Unfortunately burning different stuff over and over is annoying. How to do something nice and usable?

What you need is a dhcp server, tftp server and PXE ready client machines (most of newer hardware has ability to boot from network over PXE).

Setting dhcp server.

Beside standard network settings in dhcpd.conf you will need:

allow booting ;
allow bootp ;
next-server 192.168.0.250 ;
filename “/pxelinux.0” ;

Setting tftp server

Under PLD that means just installing atftpd package. If you built from sources then run something like:

atftpd -v5 –daemon /var/lib/tftp

Note that atftpd can not serve images bigger than 64MB (due to lack of block number rollover support). tftpd-hpa supports this fortunately.

pxelinux

You will also need syslinux package that comes with pxelinux. pxelinux will load multiple images for us depending on user choice. Use latest available version (3.31 at this moment) because older version miss important piece of functionality (menus).

/var/lib/tftp preparation

Structure I use is shown below. The most important thing is a pxelinux.0 file (symlink to real file in my case) that is whole pxelinux loader that comes with syslinux package. pxelinux uses configuration file from pxelinux.cfg directory. pxelinux tries to load various configuration files and stops at first found:

Jan 13 15:29:12 arm atftpd[5234]: Serving /pxelinux.cfg/01-00-a0-cc-da-d9-3c to 192.168.0.113:57089
Jan 13 15:29:12 arm atftpd[5234]: Serving /pxelinux.cfg/C0A80071 to 192.168.0.113:57090
Jan 13 15:29:12 arm atftpd[5234]: Serving /pxelinux.cfg/C0A8007 to 192.168.0.113:57091
Jan 13 15:29:12 arm atftpd[5234]: Serving /pxelinux.cfg/C0A800 to 192.168.0.113:57092
Jan 13 15:29:12 arm atftpd[5234]: Serving /pxelinux.cfg/C0A80 to 192.168.0.113:57093
Jan 13 15:29:12 arm atftpd[5234]: Serving /pxelinux.cfg/C0A8 to 192.168.0.113:57094
Jan 13 15:29:12 arm atftpd[5234]: Serving /pxelinux.cfg/C0A to 192.168.0.113:57095
Jan 13 15:29:12 arm atftpd[5234]: Serving /pxelinux.cfg/C0 to 192.168.0.113:57096
Jan 13 15:29:12 arm atftpd[5234]: Serving /pxelinux.cfg/C to 192.168.0.113:57097
Jan 13 15:29:12 arm atftpd[5234]: Serving /pxelinux.cfg/default to 192.168.0.113:57098

This means that we can have different configurations for different machines (based on MAC address of machine ehternet card). I’m using default configuration file which is always tried.

My entire /var/lib/tftp structure:

[root@arm /var/lib/tftp]# ls -alR
.:
total 1456
drwxr-xr-x 9 root root 4096 Jan 13 15:26 .
drwxr-xr-x 35 root root 4096 Jan 12 17:35 ..
-rw-r–r– 1 root root 5237 Jan 13 15:25 pxe-background.png
lrwxrwxrwx 1 root root 30 Jan 12 17:41 pxelinux.0 -> /usr/lib64/syslinux/pxelinux.0
drwxr-xr-x 2 root root 20 Jan 13 16:51 pxelinux.cfg
drwxr-xr-x 4 root root 47 Jan 12 09:47 rescue-x86-20060625
drwxr-xr-x 4 root root 47 Jan 12 11:39 rescue-x86-20070109
drwxr-xr-x 4 root root 47 Jan 12 09:47 rescue-x86_64-20060625
drwxr-xr-x 2 root root 31 Jan 12 10:37 suse-10.1
drwxr-xr-x 2 root root 60 Jan 12 10:06 suse-9.2
drwxr-xr-x 2 root root 60 Jan 12 10:05 suse-9.3
lrwxrwxrwx 1 root root 19 Jan 12 17:41 syslinux -> /usr/lib64/syslinux
-rw-r–r– 1 root root 1474560 Nov 18 1999 winb98se.img

./pxelinux.cfg:
total 8
drwxr-xr-x 2 root root 20 Jan 13 16:51 .
drwxr-xr-x 9 root root 4096 Jan 13 15:26 ..
-rw-r–r– 1 root root 2152 Jan 13 15:24 default

./rescue-x86-20060625:
total 54340
drwxr-xr-x 4 root root 47 Jan 12 09:47 .
drwxr-xr-x 9 root root 4096 Jan 13 15:26 ..
drwxr-xr-x 3 root root 104 Jun 25 2006 boot
drwxr-xr-x 2 root root 24 Jan 12 09:53 custom
-rw-r–r– 1 root root 55638528 Jun 25 2006 rescue.cpi

./rescue-x86-20060625/boot:
total 36
drwxr-xr-x 3 root root 104 Jun 25 2006 .
drwxr-xr-x 4 root root 47 Jan 12 09:47 ..
-rw-r–r– 1 root root 17131 Jun 15 2006 ElTorito.img.gz
-rw-r–r– 1 root root 744 Jun 15 2006 README
-rw-r–r– 1 root root 83 Jun 15 2006 boot.bat
-rw-r–r– 1 root root 1475 Jun 15 2006 floppy.img.gz
drwxr-xr-x 2 root root 138 Jun 25 2006 isolinux
-rwxr-xr-x 1 root root 3695 Jun 25 2006 isomod

./rescue-x86-20060625/boot/isolinux:
total 1508
drwxr-xr-x 2 root root 138 Jun 25 2006 .
drwxr-xr-x 3 root root 104 Jun 25 2006 ..
-r–r–r– 1 root root 2048 Jun 25 2006 boot.catalog
-rw-r–r– 1 root root 1594 Jun 25 2006 boot.msg
-rw-r–r– 1 root root 1443 Jun 15 2006 help.msg
-rw-r–r– 1 root root 357528 Jun 25 2006 initrd.ide
-rw-r–r– 1 root root 10440 Jun 25 2006 isolinux.bin
-rw-r–r– 1 root root 1156 Jun 15 2006 isolinux.cfg
-rw-r–r– 1 root root 94760 Jun 15 2006 memtest
-rw-r–r– 1 root root 1056768 Jun 25 2006 vmlinuz

./rescue-x86-20060625/custom:
total 4
drwxr-xr-x 2 root root 24 Jan 12 09:53 .
drwxr-xr-x 4 root root 47 Jan 12 09:47 ..
-rw-r–r– 1 root root 1024 Jun 25 2006 custom.cpio

./rescue-x86-20070109:
total 52768
drwxr-xr-x 4 root root 47 Jan 12 11:39 .
drwxr-xr-x 9 root root 4096 Jan 13 15:26 ..
drwxr-xr-x 3 root root 104 Jan 9 01:10 boot
drwxr-xr-x 2 root root 24 Jan 9 01:10 custom
-rw-r–r– 1 root root 54028800 Jan 9 01:10 rescue.cpi

./rescue-x86-20070109/boot:
total 36
drwxr-xr-x 3 root root 104 Jan 9 01:10 .
drwxr-xr-x 4 root root 47 Jan 12 11:39 ..
-rw-r–r– 1 root root 17131 Jun 15 2006 ElTorito.img.gz
-rw-r–r– 1 root root 744 Jun 15 2006 README
-rw-r–r– 1 root root 83 Jun 15 2006 boot.bat
-rw-r–r– 1 root root 1475 Jun 15 2006 floppy.img.gz
drwxr-xr-x 2 root root 138 Jan 9 01:10 isolinux
-rwxr-xr-x 1 root root 3695 Jan 9 01:10 isomod

./rescue-x86-20070109/boot/isolinux:
total 1708
drwxr-xr-x 2 root root 138 Jan 9 01:10 .
drwxr-xr-x 3 root root 104 Jan 9 01:10 ..
-r–r–r– 1 root root 2048 Jan 9 01:10 boot.catalog
-rw-r–r– 1 root root 1594 Jan 8 21:33 boot.msg
-rw-r–r– 1 root root 1443 Jun 15 2006 help.msg
-rw-r–r– 1 root root 381123 Jan 9 01:10 initrd.ide
-rw-r–r– 1 root root 10440 Jan 9 01:10 isolinux.bin
-rw-r–r– 1 root root 1156 Jun 15 2006 isolinux.cfg
-rw-r–r– 1 root root 94760 Jun 15 2006 memtest
-rw-r–r– 1 root root 1234944 Jan 9 01:05 vmlinuz

./rescue-x86-20070109/custom:
total 4
drwxr-xr-x 2 root root 24 Jan 9 01:10 .
drwxr-xr-x 4 root root 47 Jan 12 11:39 ..
-rw-r–r– 1 root root 1024 Jan 9 01:10 custom.cpio

./rescue-x86_64-20060625:
total 44900
drwxr-xr-x 4 root root 47 Jan 12 09:47 .
drwxr-xr-x 9 root root 4096 Jan 13 15:26 ..
drwxr-xr-x 3 root root 104 Jun 25 2006 boot
drwxr-xr-x 2 root root 24 Jun 25 2006 custom
-rw-r–r– 1 root root 45970224 Jun 25 2006 rescue.cpi

./rescue-x86_64-20060625/boot:
total 36
drwxr-xr-x 3 root root 104 Jun 25 2006 .
drwxr-xr-x 4 root root 47 Jan 12 09:47 ..
-rw-r–r– 1 root root 17131 Jun 15 2006 ElTorito.img.gz
-rw-r–r– 1 root root 744 Jun 15 2006 README
-rw-r–r– 1 root root 83 Jun 15 2006 boot.bat
-rw-r–r– 1 root root 1475 Jun 15 2006 floppy.img.gz
drwxr-xr-x 2 root root 138 Jun 25 2006 isolinux
-rwxr-xr-x 1 root root 3695 Jun 25 2006 isomod

./rescue-x86_64-20060625/boot/isolinux:
total 1776
drwxr-xr-x 2 root root 138 Jun 25 2006 .
drwxr-xr-x 3 root root 104 Jun 25 2006 ..
-r–r–r– 1 root root 2048 Jun 25 2006 boot.catalog
-rw-r–r– 1 root root 1530 Jun 25 2006 boot.msg
-rw-r–r– 1 root root 1197 Jun 18 2006 help.msg
-rw-r–r– 1 root root 364891 Jun 25 2006 initrd.ide
-rw-r–r– 1 root root 10440 Jun 25 2006 isolinux.bin
-rw-r–r– 1 root root 701 Jun 15 2006 isolinux.cfg
-rw-r–r– 1 root root 94760 Jun 15 2006 memtest
-rw-r–r– 1 root root 1321472 Jun 25 2006 vmlinuz

./rescue-x86_64-20060625/custom:
total 4
drwxr-xr-x 2 root root 24 Jun 25 2006 .
drwxr-xr-x 4 root root 47 Jan 12 09:47 ..
-rw-r–r– 1 root root 1024 Jun 25 2006 custom.cpio

./suse-10.1:
total 9164
drwxr-xr-x 2 root root 31 Jan 12 10:37 .
drwxr-xr-x 9 root root 4096 Jan 13 15:26 ..
-rw-r–r– 1 root root 8137429 May 3 2006 initrd
-rw-r–r– 1 root root 1237785 May 3 2006 linux

./suse-9.2:
total 12972
drwxr-xr-x 2 root root 60 Jan 12 10:06 .
drwxr-xr-x 9 root root 4096 Jan 13 15:26 ..
-rw-r–r– 1 root root 5379369 Oct 21 2004 initrd
-rw-r–r– 1 root root 4730075 Oct 20 2004 initrd64
-rw-r–r– 1 root root 1555945 Oct 21 2004 linux
-rw-r–r– 1 root root 1608082 Oct 20 2004 linux64

./suse-9.3:
total 14932
drwxr-xr-x 2 root root 60 Jan 12 10:05 .
drwxr-xr-x 9 root root 4096 Jan 13 15:26 ..
-rw-r–r– 1 root root 6183757 Mar 24 2005 initrd
-rw-r–r– 1 root root 6048487 Mar 24 2005 initrd64
-rw-r–r– 1 root root 1424645 Mar 24 2005 linux
-rw-r–r– 1 root root 1625590 Mar 24 2005 linux64

rescue-* directories contain unmodified copy of PLD RescueCD ISO images content. suse-* contain kernel images and initrd file copied from SuSE installation cdrom/dvd. winb98se.img is a image of Windows 98 SE boot floppy disk.

pxelinux “default” configuration file

The configuration file is shown below. vesamenu.c32 allows do display menus in graphical mode with background jpg/png images. For pure text mode there is menu.c32. MENU LABEL allows to add text message shown in menu for single label part of configuration.

“^” is used to mark keyboard shortcut letter.

Windows floppy image uses special loader called memdisk which allows to boot legacy operating systems.

CPU identification case is interesting because it starts entire new “program” named cpuidtest.c32 which is the same kind of “program” as vesamenu.c32. That’s way of handling allows us to create multiple submenus which will read different configuration files specified in APPEND directive – example:

LABEL newmenu
MENU LABEL New Menu
KERNEL vesamenu.c32
APPEND something.conf newmenu.conf

I don’t use submenus in my setup though.

[root@arm /var/lib/tftp]# cat pxelinux.cfg/default
DEFAULT syslinux/vesamenu.c32
MENU BACKGROUND pxe-background.png
PROMPT 0

MENU TITLE Remote Boot Services

label rescue-x86
MENU LABEL ^1. PLD Rescue 20060625 x86
kernel rescue-x86-20060625/boot/isolinux/vmlinuz
append initrd=rescue-x86-20060625/rescue.cpi,rescue-x86-20060625/custom/custom.cpio root=/dev/ram0 CONF=”`/dev/fd0:/rescue`;;;;;;;;;;;”
ipappend 1

label rescue-x86
MENU LABEL ^2. PLD Rescue 20070109 x86
kernel rescue-x86-20070109/boot/isolinux/vmlinuz
append initrd=rescue-x86-20070109/rescue.cpi,rescue-x86-20070109/custom/custom.cpio root=/dev/ram0 CONF=”`/dev/fd0:/rescue`;;;;;;;;;;;”
ipappend 1

label rescue-x86_64
MENU LABEL ^3. PLD Rescue 20060625 x86_64
kernel rescue-x86_64-20060625/boot/isolinux/vmlinuz
append initrd=rescue-x86_64-20060625/rescue.cpi,rescue-x86_64-20060625/custom/custom.cpio root=/dev/ram0 CONF=”`/dev/fd0:/rescue`;;;;;;;;;;;”

label suse-install-9.2-x86
MENU LABEL ^4. SuSE Linux Install 9.2 x86
kernel suse-9.2/linux
append initrd=suse-9.2/initrd splash=silent showopts install=ftp://192.168.1.250/SUSE/9.2

label suse-install-9.2-x86_64
MENU LABEL ^5. SuSE Linux Install 9.2 x86_64
kernel suse-9.2/linux64
append initrd=suse-9.2/initrd64 splash=silent showopts install=ftp://192.168.1.250/SUSE/9.2

label suse-install-9.3-x86
MENU LABEL ^6. SuSE Linux Install 9.3 x86
kernel suse-9.3/linux
append initrd=suse-9.3/initrd splash=silent showopts install=ftp://192.168.1.250/SUSE/9.3

label suse-install-9.3-x86_64
MENU LABEL ^7. SuSE Linux Install 9.3 x86_64
kernel suse-9.3/linux64
append initrd=suse-9.3/initrd64 splash=silent showopts install=ftp://192.168.1.250/SUSE/9.3

label suse-install-10.1-x86
MENU LABEL ^8. SuSE Linux Install 10.1 x86
kernel suse-10.1/linux
append initrd=suse-10.1/initrd splash=silent showopts install=ftp://192.168.1.250/SUSE/10.1

label win98se
MENU LABEL ^9. Windows 98 SE Boot Disk
kernel syslinux/memdisk
append initrd=winb98se.img

LABEL cpuid
MENU LABEL ^A. Identify Processor
KERNEL syslinux/cpuidtest.c32

Screenphotos

(click images to see in full size))

Text boot using menu.c32 (or when vesamenu.c32 gets wrong options, files like background image in wrong size (needs to be 640×480)).

Text boot

Graphical boot with PLD-style background image.

Graphical boot

You can change boot options just like in grub.

Graphical boot with editing parameters for single boot entry

PLD RescueCD boots…

Booting PLD RescueCD

Windows 98 SE image already started.

Booting Windows 98 SE floppy image

Example of CPU Identification that comes with syslinux package.

CPU Identification example

Background image used in screenshots

PLD Background

2 thoughts on “PXE remote boot for your home/work lab

  1. abram says:

    very nice description!

    i must try it in my network (small toshiba without cdrom, can boot from network, some portege or something )

    😎

    Reply to abram

  2. Dan says:

    I just wanted to say thank you. This page was very helpful in setting up a vesamenu.c32 system for our lab. Thanks!

    Reply to Dan

Leave a Reply

Your email address will not be published. Required fields are marked *