From One to a Thousand: A Hands‑On PXE Guide for Batch Server Installation
This tutorial walks you through the entire process of setting up a PXE‑based automated OS installation pipeline—from understanding different bulk‑install methods and the PXE workflow to configuring DHCP, TFTP, HTTP services, creating Kickstart files, handling UEFI vs BIOS, and troubleshooting common pitfalls—so you can provision dozens or hundreds of servers with a single command.
1. Bulk Installation Methods and Their Trade‑offs
Four common ways to install many servers are compared:
USB clone (Clonezilla / dd) : Create an image on one machine and copy it via USB or multicast. Works for a few machines; large image size and manual USB insertion are drawbacks.
USB with auto‑answer file : Prepare a universal USB containing the OS ISO and a Kickstart (CentOS) or autoinstall (Ubuntu) file. Installation is unattended but still requires plugging the USB into each server.
PXE network boot (recommended) : Servers boot from the network, download a bootloader, kernel and initrd, then fetch a Kickstart file to complete installation automatically. No USB, no manual steps, and can handle many machines simultaneously.
Cloud‑platform tools (Cobbler / Foreman) : Provide a web UI and API on top of PXE. They still rely on PXE underneath, so mastering PXE is foundational.
2. How PXE Works
The PXE boot sequence consists of five stages:
DHCP request : The server’s NIC broadcasts a DHCP request asking for an IP address and boot information.
DHCP response : The PXE server replies with the client’s IP, the TFTP server address (next‑server), and the boot file name.
TFTP download of the boot program : The client retrieves pxelinux.0 (BIOS) or grubx64.efi (UEFI) via TFTP.
Load kernel and initrd : The bootloader reads its configuration, then downloads vmlinuz and initrd.img via TFTP.
Kernel start + automatic install : The kernel boots with a ks=http://… (or autoinstall) parameter, fetches the Kickstart/autoinstall file from an HTTP server, and proceeds through partitioning, package installation, network setup, etc., without human interaction.
The three core components are the DHCP server, the TFTP server, and an HTTP/FTP/NFS server that hosts the OS files and answer file.
3. Hands‑On: Build a PXE Server (CentOS 7 Example)
3.1 Install required packages
yum install -y dhcp tftp-server syslinux httpdThese packages provide the DHCP daemon, TFTP daemon, Syslinux bootloader, and Apache HTTP server.
3.2 Configure DHCP
Edit /etc/dhcp/dhcpd.conf:
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option domain-name-servers 8.8.8.8;
option routers 192.168.1.1;
next-server 192.168.1.10;
filename "pxelinux.0";
}Key parameters are next-server (PXE server IP) and filename (boot file name, BIOS vs UEFI).
3.3 Configure TFTP
Enable TFTP in /etc/xinetd.d/tftp by changing disable = yes to disable = no. Then copy the bootloader and create the TFTP root:
# Copy pxelinux.0
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
# Copy menu module
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
# Create config directory
mkdir -p /var/lib/tftpboot/pxelinux.cfg
# Mount CentOS ISO and copy kernel/initrd
mount -o loop /path/to/CentOS-7-x86_64-DVD.iso /mnt
mkdir -p /var/lib/tftpboot/centos7
cp /mnt/isolinux/vmlinuz /var/lib/tftpboot/centos7/
cp /mnt/isolinux/initrd.img /var/lib/tftpboot/centos7/3.4 Create PXE boot menu
Write /var/lib/tftpboot/pxelinux.cfg/default:
default menu.c32
prompt 0
timeout 60
menu title ===== Server Batch Install Menu =====
label centos7-auto
menu label ^1) CentOS 7 Auto Install
kernel centos7/vmlinuz
append initrd=centos7/initrd.img ks=http://192.168.1.10/ks/centos7.ks
label centos7-manual
menu label ^2) CentOS 7 Manual Install
kernel centos7/vmlinuz
append initrd=centos7/initrd.img method=http://192.168.1.10/centos/7/os/x86_64/
label local
menu label ^3) Boot Local Disk
localboot 0The timeout 60 makes the menu auto‑select after 60 seconds; the ks= parameter points to the Kickstart file.
3.5 Configure HTTP server (install source + Kickstart)
Mount the CentOS ISO into Apache’s document root:
mkdir -p /var/www/html/centos/7/os/x86_64
mount -o loop /path/to/CentOS-7-x86_64-DVD.iso /var/www/html/centos/7/os/x86_64/Create the Kickstart file /var/www/html/ks/centos7.ks:
#platform=x86, AMD64, or Intel EM64T
lang zh_CN.UTF-8
keyboard us
network --bootproto=dhcp --onboot=yes
rootpw --iscrypted $6$rounds=656000$salt$hash
firewall --disabled
selinux --disabled
timezone Asia/Shanghai
clearpart --all --initlabel
part /boot --fstype="ext4" --size=500
part / --fstype="ext4" --size=50000
part swap --size=4096
url --url="http://192.168.1.10/centos/7/os/x86_64/"
%packages
@core
wget
vim
net-tools
%end
%post
echo "PXE install complete!" > /root/install_done.txt
%endNote that clearpart --all --initlabel wipes all disks; in production add drives=sda to limit the operation.
3.6 Start all services
systemctl start dhcpd tftp httpd
systemctl enable dhcpd tftp httpdVerify listening ports with netstat -tulnp | grep -E "67|69|80"; you should see UDP 67 (DHCP), UDP 69 (TFTP) and TCP 80 (HTTP).
3.7 Test PXE boot
Set a target server’s BIOS to boot from network, power on, and observe:
DHCP lease acquisition
TFTP download progress
Display of the custom boot menu
Selection of “Auto Install” triggers a fully unattended installation
In a real deployment the workflow installed 48 servers by powering the rack and waiting for the automation.
4. UEFI vs BIOS – Common Pitfall
UEFI machines require grubx64.efi instead of pxelinux.0. DHCP configuration must include a conditional:
if option architecture-type = 00:07 or option architecture-type = 00:09 then
filename "grubx64.efi";
else
filename "pxelinux.0";
endCopy the UEFI boot files from the ISO into the TFTP root:
cp /mnt/EFI/BOOT/grubx64.efi /var/lib/tftpboot/
cp /mnt/EFI/BOOT/BOOTX64.EFI /var/lib/tftpboot/
cp /mnt/images/efiboot.img /var/lib/tftpboot/
mkdir -p /var/lib/tftpboot/grub2
cp /mnt/EFI/BOOT/grub.cfg /var/lib/tftpboot/grub2/A failure case is described where all servers were UEFI but the DHCP config served the BIOS boot file, causing boot failures.
5. USB‑Based Batch Install (Fallback)
When PXE is unavailable, USB‑based solutions are outlined:
CentOS: write ISO to USB, add isolinux/ks.cfg, and modify isolinux.cfg to include ks=hd:sdb1:/isolinux/ks.cfg.
Ubuntu 22.04+: create /var/lib/cloud/seed/nocloud-net/ with user-data and meta-data, add autoinstall ds=nocloud to kernel parameters.
Efficiency tips include using multiple USB sticks, setting USB as first boot device, leveraging IPMI virtual media, or using Ventoy to hold multiple ISOs.
6. Clonezilla for Homogeneous Environments
When hardware is identical, Clonezilla can clone disks locally or via multicast. The author reports that 50 machines restored a 10 GB image in about 15 minutes using multicast, which requires a DRBL server (essentially PXE + Clonezilla).
7. Production‑Grade Best Practices and Gotchas
Network isolation : PXE relies on DHCP broadcast; ensure servers and PXE host share a VLAN or configure DHCP relay.
Firewall rules : Open UDP 67/68, UDP 69, and TCP 80; many failures stem from blocked TFTP port.
Secure Boot : Unsigned bootloaders are rejected; either disable Secure Boot or use signed GRUB binaries.
Disk partitioning : Avoid hard‑coded sizes; use --grow or --percent for flexible layouts.
Pre‑deployment testing : Validate DHCP, TFTP, HTTP, and Kickstart syntax on a few machines before scaling.
Logging : Check /var/log/messages on the PXE server for DHCP/TFTP logs and /var/log/anaconda/ on the client for installer output.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
AI Agent Super App
AI agent applications, installation, large-model testing, computer fundamentals, IT operations and maintenance exchange, network technology exchange, Linux learning
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
