PXE Booting
DHCP Server
Configure a DHCP server and set the next-server
and filename
options.
subnet 192.168.254.0 netmask 255.255.255.0 {
...
next-server 192.168.254.2; # This is the TFTP server address
filename "grub/grubx64.efi"; # This is the path to the GRUB bootloader
...
}
note
DHCP option codes 67 and 68 are not used for PXE booting!
PXE Server
Configure a PXE booting server with the following dependencies:
TFP Service
Install a TFTP server package:
sudo apt install tftpd-hpa
Configure the TFTP service:
/etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure"
RUN_DAEMON="yes
Start and enable the TFTP service:
sudo systemctl restart tftpd-hpa
sudo systemctl enable tftpd-hpa
HTTP Service
Install a HTTP server to host any ISO images:
sudo apt install nginx
Preparing the Boot Images for Linux
Ubuntu
- Create distro specific folders in the root of the TFTP server
mkdir -p /srv/tftp/ubuntu/22.04/
- Download the latest live server ISO for the release you want to install:
wget https://cdimage.ubuntu.com/ubuntu-server/noble/daily-live/current/noble-live-server-amd64.iso
- Mount the ISO
mount noble-live-server-amd64.iso /mnt
- Copy the kernel and
initrd
from the ISO to the TFTP folder
cp /mnt/casper/{vmlinuz,initrd} /srv/tftp/ubuntu/22.04
TODO: Prepare cloud-init files
Rocky
- Create distro specific folders in the root of the TFTP server
mkdir -p /srv/tftp/rocky/9/
- Download the kernel and boot image from download.rockylinux.org
wget https://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/isolinux/vmlinuz
wget https://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/isolinux/initrd.img
- Create kickstart files and place into the root of the HTTP server
rocky
└── 9
├── r9.ks
└── r9-wks.ks
2 directories, 2 files
Preparing the Boot Menu for UEFI
- Create a
grub/
folder at the root of the TFTP server
mkdir -p /srv/tftp/grub/
- Download and copy the signed GRUB bootloader to the
grub/
folder in the root of the TFTP server.
apt download grub-efi-amd64-signed
dpkg-deb --fsys-tarfile grub-efi-amd64-signed*deb | tar x ./usr/lib/grub/x86_64-efi-signed/grubnetx64.efi.signed -O > /srv/tftp/grub/grubx64.efi
- Create the grub.cfg file and place into the grub/ folder
touch /srv/tftp/grub/grub.cfg
- Begin building the
grub.cfg
file and define any themes you wish to use.
set theme=/grub/themes/pxe/theme.txt
set default=0
set timeout=-1
terminal_output gfxter
set gfxpayload=keep
- Build out the boot menu entries for each OS
menuentry 'Install Ubuntu 22.04 (Server)' --class ubuntu {
linux ubuntu/22.04/vmlinuz ip=dhcp url=http://192.168.254.2/ubuntu-22.04.4-live-server-amd64.iso autoinstall ds=nocloud-net;s=http://192.168.254.2/ubuntu/
initrd ubuntu/22.04/initrd
}
menuentry 'Install Rocky Linux 9 (Server)' --class linux {
linux rocky/9/vmlinuz ip=dhcp inst.ks=http://192.168.254.2/rocky/9/r9.ks
initrd rocky/9/initrd.img
}