PXE Boot #
Introduction #
The Preboot eXecution Environment (PXE) is a technique that enables the distribution of arbitrary executable code or user data over the network. This can be used for example emergency systems or an Installation media without a USB stick.
Setup of a PXE server #
The following software is required:
- DHCP server (dhcpd, dnsmasq)
- TFTP server (tftp-hpa, dnsmasq)
- NFS server / HTTP server (nfs-server, nginx, darkhttpd)
- Bootloader (syslinux)
The client to be booted must have a PXE-enabled network card. The PXE code will then first configure the interface via DHCP and gets the extended information like the TFTP server and bootloader file address. Afterwards the client can load the initial Network Bootstrap Program (NBP) and execute it in memory. A possible bootloader program is PXELinux.
sequenceDiagram participant C as PXE-Client participant S as DHCP-Server (PXE-fähig) participant T as TFTP-Server C->>+S: Extended DHCP Discover Port 67 S-->>-C: Extended DHCP Offer Port 68 C->>+S: DHCP Request Port 67 S-->>-C: DHCP Boot Ack. Reply Port 68 C->>+S: Boot Service Discover Port 67 oder 4011 S-->>-C: Boot ServiceAck. Reply Port 67 oder 4011 C->>+T: Bootstrap Program Download Request Port 69 T-->>-C: Bootstrap Program Download Port 69
Proxy DHCP #
Since the DHCP server is not always under the control of the developer, the Proxy DHCP solution is needed. In addition to the conventional DHCP exchange, supplementary information is sent from the Proxy DHCP Server.
Example Setup #
In this example Syslinux is used directly from Archlinux ISO.
4 images are configured (2 times Archlinux, Clonezilla).
File structure #
The ISO file is to be mounted, and then the necessary files are copied from it. The Syslinux folder becomes the root folder. Afterwards a directory is created in the root folder, where the images (e.g. Clonezilla, Archlinux etc.) should be stored.
tftp
├── hdt
├── images
│ ├── arch
│ │ ├── boot
│ │ │ ├── x86_64
│ │ │ │ ├── initramfs-linux.img
│ │ │ │ └── vmlinuz-linux
│ │ ├── x86_64
│ │ │ ├── airootfs.sfs
│ │ │ ├── airootfs.sfs.sig
│ │ │ └── airootfs.sha512
│ ├── archlinux-2021.06.01-x86_64.iso
│ └── clonezilla-live-2.7.2-39-amd64.iso
├── archiso_head.cfg
├── archiso_pxe.cfg
├── archiso_pxe-linux.cfg
├── archiso_sys.cfg
├── archiso_sys-linux.cfg
├── archiso_tail.cfg
├── lpxelinux.0
├── splash.png
DHCP Server #
interface=vboxnet0
listen-address=192.168.56.1
dhcp-range=192.168.56.10,192.168.56.30,12h
dhcp-option-force=209,syslinux.cfg
dhcp-boot=lpxelinux.0
enable-tftp
tftp-root=/mnt/tftp
log-dhcp
Syslinux Config #
syslinux.cfg #
DEFAULT select
LABEL select
COM32 whichsys.c32
APPEND -pxe- pxe -sys- sys -iso- sys
LABEL pxe
CONFIG archiso_pxe.cfg
LABEL sys
CONFIG archiso_sys.cfg
archiso_pxe.cfg #
INCLUDE archiso_head.cfg
INCLUDE archiso_pxe-linux.cfg
INCLUDE archiso_tail.cfg
archiso_head.cfg #
SERIAL 0 115200
UI vesamenu.c32
MENU TITLE Arch Linux
MENU BACKGROUND splash.png
MENU WIDTH 78
MENU MARGIN 4
MENU ROWS 7
MENU VSHIFT 10
MENU TABMSGROW 14
MENU CMDLINEROW 14
MENU HELPMSGROW 16
MENU HELPMSGENDROW 29
# Refer to http://syslinux.zytor.com/wiki/index.php/Doc/menu
MENU COLOR border 30;44 #40ffffff #a0000000 std
MENU COLOR title 1;36;44 #9033ccff #a0000000 std
MENU COLOR sel 7;37;40 #e0ffffff #20ffffff all
MENU COLOR unsel 37;44 #50ffffff #a0000000 std
MENU COLOR help 37;40 #c0ffffff #a0000000 std
MENU COLOR timeout_msg 37;40 #80ffffff #00000000 std
MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std
MENU COLOR msg07 37;40 #90ffffff #a0000000 std
MENU COLOR tabmsg 31;40 #30ffffff #00000000 std
MENU CLEAR
MENU IMMEDIATE
archiso_pxe-linux.cfg #
# Entpacktes ISO, es wird ein HTTP Server benötigt
LABEL arch64_http
TEXT HELP
Boot the Arch Linux live medium using HTTP.
It allows you to install Arch Linux or perform system maintenance.
ENDTEXT
MENU LABEL Arch Linux install medium (x86_64, HTTP)
LINUX /images/arch/boot/x86_64/vmlinuz-linux
INITRD /images/arch/boot/intel-ucode.img,/images/arch/boot/amd-ucode.img,/images/arch/boot/x86_64/initramfs-linux.img
APPEND archisobasedir=/images/arch archiso_http_srv=http://${pxeserver}/ checksum verify
SYSAPPEND 3
# ISOs
LABEL arch-iso
LINUX memdisk
INITRD /images/archlinux-2021.06.01-x86_64.iso
APPEND iso
LABEL clonezilla-iso
LINUX memdisk
INITRD /images/clonezilla-live-2.7.2-39-amd64.iso
APPEND iso
archiso_tail.cfg #
LABEL existing
TEXT HELP
Boot an existing operating system.
Press TAB to edit the disk and partition number to boot.
ENDTEXT
MENU LABEL Boot existing OS
COM32 chain.c32
APPEND hd0 0
# http://www.memtest.org/
LABEL memtest
MENU LABEL Run Memtest86+ (RAM test)
LINUX /arch/boot/memtest
# http://hdt-project.org/
LABEL hdt
MENU LABEL Hardware Information (HDT)
COM32 hdt.c32
APPEND modules_alias=hdt/modalias.gz pciids=hdt/pciids.gz
LABEL reboot
TEXT HELP
Reboot computer.
The computer's firmware must support APM.
ENDTEXT
MENU LABEL Reboot
COM32 reboot.c32
LABEL poweroff
TEXT HELP
Power off computer.
The computer's firmware must support APM.
ENDTEXT
MENU LABEL Power Off
COM32 poweroff.c32