PXE (Preboot eXecution Environment)
Environment
Field | Spec or Version |
---|---|
CPU | QEMU Virtual CPU version 2.5+ (2 Cores) |
RAM | 2G |
OS | Rocky Linux 10.0 (Red Quartz) |
Network | interface ens18 with static IP 192.168.3.11/24 |
DNS | 192.168.3.1 (Private DNS Server) |
Package Installation
dnf install -y syslinux syslinux-tftpboot dnsmasq nfs-utils exportfs rsync
Package Configuration
-
Mount Ubuntu Live Iso
export ISO_MP='/media/iso' mkdir -p "$ISO_MP" mount /dev/sr0 "$ISO_MP"
-
/etc/dnsmasq.conf
# Listen on this specific port instead of the standard DNS port # (53). Setting this to zero completely disables DNS function, # leaving only DHCP and/or TFTP. port=0 # If you want dnsmasq to listen for DHCP and DNS requests only on # specified interfaces (and the loopback) give the name of the # interface (eg eth0) here. # Repeat the line for more than one interface. interface=ens18 # Uncomment this to enable the integrated DHCP server, you need # to supply the range of addresses available for lease and optionally # a lease time. If you have more than one network, you will need to # repeat this for each network on which you want to supply DHCP # service. dhcp-range=192.168.3.200,192.168.3.250,12h # Override the default route supplied by dnsmasq, which assumes the # router is the same machine as the one running dnsmasq. # Do the same thing, but using the option name dhcp-option=option:router,192.168.3.1 dhcp-option=option:dns-server,192.168.3.1 # Set the boot filename for netboot/PXE. You will only need # this if you want to boot machines over the network and you will need # a TFTP server; either dnsmasq's built-in TFTP server or an # external one. (See below for how to enable the TFTP server.) dhcp-boot=syslinux.efi # Enable dnsmasq's built-in TFTP server enable-tftp # Set the root directory for files available via FTP. tftp-root=/var/tftp # Log lots of extra information about DHCP transactions. log-dhcp
-
Init TFTP server provided by dnsmasq
TFTP only provides basic files for PXE, like bootloader, boot menu, and initrd entry.
export TFTP_PATH='/var/tftp' mkdir -p "$TFTP_PATH" # PXE bootloader # Alter: copy these files from Ubuntu distro if files from rocky failed. cp /tftpboot/efi64/syslinux.efi "$TFTP_PATH" cp /tftpboot/efi64/ldlinux.e64 "$TFTP_PATH" # PXE boot menu mkdir "$TFTP_PATH/pxelinux.cfg" cat > "$TFTP_PATH/pxelinux.cfg/default" <<'EOF' DEFAULT ubuntu LABEL ubuntu KERNEL ubuntu/vmlinuz INITRD ubuntu/initrd APPEND boot=casper netboot=nfs nfsroot=192.168.3.11:/srv/ubuntu-live ip=dhcp --- EOF # PXE boot option1 - Ubuntu export TFTP_UBUNTU_PATH="$TFTP_PATH/ubuntu" mkdir -p "$TFTP_UBUNTU_PATH" cp "$ISO_MP/casper/initrd" "$TFTP_UBUNTU_PATH" cp "$ISO_MP/casper/vmlinuz" "$TFTP_UBUNTU_PATH" chown -R dnsmasq: "$TFTP_PATH" chcon -R -t tftpdir_t "$TFTP_PATH"
-
Init NFS server
NFS provides actual live OS because OS files is too large to TFTP for transfer. TFTP only transfer files with max size about 100M stably.
export NFS_UBUNTU_PATH='/srv/ubuntu-live' mkdir -p "$NFS_UBUNTU_PATH" rsync -a "$ISO_MP/" "$NFS_UBUNTU_PATH/" chcon -R -t nfs_t "$NFS_UBUNTU_PATH" cat >> /etc/exports <<EOF $NFS_UBUNTU_PATH *(ro,sync,no_subtree_check) EOF
-
Unmount Ubuntu Live Iso
umount "$ISO_MP" rmdir "$ISO_MP"
Final Checks
-
tree "$TFTP_PATH"
/var/tftp โโโ ldlinux.e64 โโโ pxelinux.cfg โย ย โโโ default โโโ syslinux.efi โโโ ubuntu โโโ initrd โโโ vmlinuz 3 directories, 5 files
-
tree -L 2 "$NFS_UBUNTU_PATH"
/srv/ubuntu-live โโโ boot โย ย โโโ grub โย ย โโโ memtest86+x64.bin โโโ boot.catalog โโโ casper โย ย โโโ filesystem.manifest โย ย โโโ filesystem.size โย ย โโโ initrd โย ย โโโ install-sources.yaml โย ย โโโ ubuntu-server-minimal.manifest โย ย โโโ ubuntu-server-minimal.size โย ย โโโ ubuntu-server-minimal.squashfs โย ย โโโ ubuntu-server-minimal.squashfs.gpg โย ย โโโ ubuntu-server-minimal.ubuntu-server.installer.generic.manifest โย ย โโโ ubuntu-server-minimal.ubuntu-server.installer.generic.size โย ย โโโ ubuntu-server-minimal.ubuntu-server.installer.generic.squashfs โย ย โโโ ubuntu-server-minimal.ubuntu-server.installer.generic.squashfs.gpg โย ย โโโ ubuntu-server-minimal.ubuntu-server.installer.manifest โย ย โโโ ubuntu-server-minimal.ubuntu-server.installer.size โย ย โโโ ubuntu-server-minimal.ubuntu-server.installer.squashfs โย ย โโโ ubuntu-server-minimal.ubuntu-server.installer.squashfs.gpg โย ย โโโ ubuntu-server-minimal.ubuntu-server.manifest โย ย โโโ ubuntu-server-minimal.ubuntu-server.size โย ย โโโ ubuntu-server-minimal.ubuntu-server.squashfs โย ย โโโ ubuntu-server-minimal.ubuntu-server.squashfs.gpg โย ย โโโ vmlinuz โโโ dists โย ย โโโ noble โย ย โโโ stable -> noble โย ย โโโ unstable -> noble โโโ EFI โย ย โโโ boot โโโ install โโโ md5sum.txt โโโ pool โย ย โโโ main โย ย โโโ restricted โโโ ubuntu -> . 15 directories, 24 files
Service Restart
firewall-cmd --permanent --add-service=dhcp
firewall-cmd --permanent --add-service=tftp
# NFS
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --permanent --add-service=mountd
firewall-cmd --reload
systemctl enable --now dnsmasq
systemctl restart dnsmasq
exportfs -ra
systemctl enable --now nfs-server
systemctl restart nfs-server
Create another PXE client
- No disk or disc required for PXE boot
- Enable PXE boot
Troubleshoot
If your PXE client stucks at UEFI boot, your files in /var/tftp/
are possibly bad.
The Syslinux EFI implementation is incomplete/buggy in many RHEL/Fedora/Rocky builds, so you can copy them from Ubuntu repo directly.
No Comments