Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Building a PXE-Based Automated Network Deployment Service

Tech May 9 4

PXE (Preboot Execution Environment) enables computers to boot and load an operating system over the network, facilitating rapid mass deployment of servers, recovery tasks, and diskless operation. It leverages DHCP and TFTP protocols to deliver boot files and OS images without relying on local storage.

Core Concepts

PXE operates through five stages:

  1. Power-on Initiation – BIOS/UEFI triggers the integrated PXE client, which broadcasts a request on the network.
  2. DHCP Reply – A DHCP server responds with IP configuration and the location of the boot loader.
  3. TFTP Retrieval – The client downloads a minimal boot program via TFTP from the indicated server.
  4. Boot Program Execution – The retrieved boot stub may start a lightweight OS environment or load a full installer.
  5. OS Image Loading – With assistance from the boot program, the complete operating system image is loaded and started.

Required Services and Components

  • DHCP daemon – Assigns IP addresses and informs clients about the TFTP endpoint and boot file name.
  • TFTP daemon – Serves the initial boot loader and related assets; chosen for its simplicity in pre-boot environments.
  • File share service (FTP, HTTP, or NFS) – Hosts the OS installation tree and optional package repositories.
  • Client prerequisites – Network interface with PXE firmware support and motherboard configured for network boot.

Deployment Architecture Overview

The workflow resembles a delivery process: DHCP allocates addressing, then the boot server supplies the installation "package". The client unpacks and follows predefined instructions to complete setup.

Preparing the Deployment Host

Use a Linux host (example: Rocky Linux 8.6, 2 vCPU, 2 GB RAM) at IP 192.168.88.20. Target nodes will run the same OS version.

Steps:

  1. Configure DHCP to provide addressing and point to the TFTP boot server and file.
  2. Stage the installation ISO content on the chosen file-sharing method.
  3. Create a Kickstart file (autoinstall.cfg) for unattended installations.
  4. Enable TFTP and populate it with PXE boot resources.
  5. Craft the PXE boot menu configuration.
  6. Verify the end-to-end flow in a test environment.

Configuring DHCP

Install the DHCP server package:

host# dnf -y install dhcp-server

Edit /etc/dhcp/dhcpd.conf:

subnet 192.168.88.0 netmask 255.255.255.0 {
    range 192.168.88.101 192.168.88.150;
    option routers 192.168.88.254;
    option broadcast-address 192.168.88.255;
    next-server 192.168.88.20;
    filename "netboot.0";
    default-lease-time 600;
    max-lease-time 7200;
}

Key entries: next-server specifies the TFTP host, and filename identifies the initial boot loader.

Start the service:

host# systemctl enable dhcpd --now

DHCP negotiation proceeds as Discovery → Offer → Request → Acknowledgement.

Setting Up File Sharing via FTP

Install and configure vsftpd:

host# dnf -y install vsftpd
host# sed -i 's/^anonymous_enable=NO/anonymous_enable=YES/' /etc/vsftpd/vsftpd.conf
host# systemctl enable vsftpd --now

Mount the ISO content:

host# mkdir -p /srv/ftp/rocky8
host# echo '/dev/sr0 /srv/ftp/rocky8 iso9660 defaults 0 0' >> /etc/fstab
host# mount -a

Verify visibility of BaseOS and AppStream directories under /srv/ftp/rocky8.

Creating an Unattended Kickstart Profile

Generate autoinstall.cfg for automated installations. Example minimal profile:

#platform=x86_64
install
url --url="ftp://192.168.88.20/rocky8"
rootpw --iscrypted $6$abcd...hashed...
firewall --disabled
selinux --disabled
keyboard us
lang en_US
timezone Asia/Shanghai
network --bootproto=dhcp --device=link --onboot=yes
bootloader --location=mbr
zerombr
clearpart --all --initlabel
part / --fstype="xfs" --grow --size=1
graphical
firstboot --disable
reboot

%packages
@core
%end

Place the file in the FTP root so PXE clients can retrieve it:

host# cp autoinstall.cfg /srv/ftp/

Deploying TFTP Resources

Install TFTP server components:

host# dnf -y install tftp-server syslinux-tftpboot
host# systemctl enable tftp --now

Locate and copy the network boot loader:

host# cp /tftpboot/netboot.0 /var/lib/tftpboot/

Transfer boot media from the mounted ISO:

host# cp /srv/ftp/rocky8/isolinux/* /var/lib/tftpboot/
host# mkdir -p /var/lib/tftpboot/pxelinux.cfg
host# cp /var/lib/tftpboot/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

Essential files:

  • vmlinuz – Compressed Linux kernel.
  • initrd.img – Initial RAM filesystem for hardware detection.
  • netboot.0 – PXE-specific boot loader.
  • vesamenu.c32 – Graphical menu renderer.
  • default – Menu definition file.

Customize /var/lib/tftpboot/pxelinux.cfg/default:

default vesamenu.c32
timeout 600
menu background splash.png
menu title Rocky Linux 8 Deployment

label os_install
  menu label ^Install Rocky Linux 8
  menu default
  kernel vmlinuz
  append initrd=initrd.img inst.ks=ftp://192.168.88.20/autoinstall.cfg net.ifnames=0

Boot Flow Summary

  1. Client boots from network; BIOS invokes PXE client.
  2. DHCP assigns address and reveals TFTP location and boot file.
  3. TFTP delivers netboot.0, which reads pxelinux.cfg/default.
  4. Menu displays options; default entry loads kernel and initrd.
  5. Kernel fetches Kickstart file and installation source via FTP.
  6. System installs automatically per Kickstart directives.

Validation

Provision a test VM with ≥2 GB RAM and network interface on the deployment subnet. Enter BIOS/UEFI to prioritize PXE boot. Observe:

  • DHCP lease acquisition.
  • Display of PXE boot menu.
  • Kernel and initrd loading.
  • Transition into graphical installer running unattended.

Common issues:

  • Insufficient memory causing hangs.
  • Incorrect permissions on Kickstart file.
  • Active firewall blocking TFTP/FTP.
  • Corrupted boot media files; verify checksums or re-copy from ISO images/pxeboot/.
  • Graphics adapter conflicts in VMs; switch to emulated display.
Tags: PXE

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.