Network-Based System Installation Using PXE
Deploying operating systems across multiple machines manually is time-consuming and inefficient. PXE (Preboot Execution Environment) enables network-based booting, allowing clients to download boot images from remote servers. This technology operates in client/server mode and is particularly useful for large-scale deployments.
Core Concepts
PXE itself is not an installation method but a boot mechanism. The PXE client resides in the network card's ROM. During system boot, the BIOS loads the PXE client into memory, which then downloads files from a remote server via the network.
PXE implementation requires both DHCP and TFTP servers. The DHCP server assigns IP addresses to PXE clients and provides the boot loader location. The TFTP server delivers the necessary boot files.
Installation Methods Comparison
- Local storage installation
- Optical media installation
- Network-based installation (PXE)
Linux Installation Sequence
1. Boot Loader Loading
The boot loader initializes hardware and prepares the environment for the kernel. Common boot loaders include GRUB and LILO.
2. Installation Menu Display
The boot loader presents options including system installation, media verification, and booting from local devices.
3. Kernel and Initrd Loading
The kernel (vmlinuz) is loaded along with initrd (initial RAM disk), which contains essential drivers for accessing the root filesystem.
4. Root Filesystem Mounting
The system mounts the actual root filesystem containing the operating system files.
5. Anaconda Installation Program
The Anaconda installer guides users through language selection, keyboard layout, network configuration, partitioning, package selection, and user account setup.
PXE Workflow
- Client network card broadcasts for DHCP server
- DHCP server assigns IP and provides boot loader and TFTP server addresses
- Client downloads boot loader via TFTP
- BIOS executes the boot loader
- Boot loader retrieves configuration from TFTP
- System installation begins based on configuration
Key Components
TFTP (Trivial File Transfer Protocol)
A lightweight UDP-based file transfer protocol using port 69. Lacks authentication and is ideal for network boot operations.
pxelinux.0
PXE boot loader from the SYSLINUX project that downloads kernel and initrd files from TFTP server and presents boot menus.
xinetd
Extended internet daemon that manages network services including TFTP, providing enhanced security and resource control.
vmlinuz
Compressed Linux kernel executable loaded during system boot.
pxelinux.cfg
Configuration directory containing boot menu definitions for PXE clients.
Implementation Steps
Required Packages
vsftpd - for installation mirror access
dhcp - for IP address allocation
syslinux - for PXE boot files
tftp-server - for boot file transfers
xinetd - for TFTP service management
system-config-kickstart - for automated installation
1. Network Configuration
Configure network interface (example: ens37):
cd /etc/sysconfig/network-scripts/
cp ifcfg-ens33 ifcfg-ens37
Edit ifcfg-ens37:
TYPE=Ethernet
BOOTPROTO=static
NAME=ens37
DEVICE=ens37
ONBOOT=yes
IPADDR=192.168.200.50
NETMASK=255.255.255.0
Restart network service:
systemctl restart network
systemctl enable network
2. Package Installation
yum install -y vsftpd dhcp tftp-server xinetd syslinux
3. DHCP Server Configuration
Edit /etc/dhcp/dhcpd.conf:
subnet 192.168.200.0 netmask 255.255.255.0 {
range 192.168.200.100 192.168.200.150;
option domain-name-servers 8.8.8.8;
option routers 192.168.200.50;
next-server 192.168.200.50;
filename "pxelinux.0";
}
ddns-update-style none;
Start DHCP service:
systemctl start dhcpd
systemctl enable dhcpd
4. TFTP Server Configuration
Edit /etc/xinetd.d/tftp:
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot -c
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
Start xinetd service:
systemctl start xinetd
systemctl enable xinetd
5. PXE Boot Configuration
Create directories and copy files:
mkdir -p /var/lib/tftpboot/pxelinux.cfg
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
mount /dev/sr0 /mnt
cp /mnt/images/pxeboot/vmlinuz /mnt/images/pxeboot/initrd.img /var/lib/tftpboot/
Create /var/lib/tftpboot/pxelinux.cfg/default:
default install
prompt 1
timeout 60
label install
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.200.50/centos7
label rescue
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.200.50/centos7
6. FTP Server Setup
Create FTP directory and copy installation source:
mkdir -p /var/ftp/centos7
cp -r /mnt/* /var/ftp/centos7/
Start vsftpd service:
systemctl start vsftpd
systemctl enable vsftpd
7. Service Verification
Check all services:
systemctl status dhcpd xinetd tftp vsftpd
ls -la /var/lib/tftpboot/
ls -la /var/ftp/centos7/
Kickstart Automated Installation
Kickstart enables automated OS deployment using pre-configured answer files. This eliminates manual intervention during installation and ensures consistency across deployments.
Kickstart Configuration File
Sample ks.cfg configuration:
# System installation
install
url --url="ftp://192.168.200.50/centos7"
# System settings
lang en_US.UTF-8
keyboard us
firewall --disabled
selinux --disabled
text
# Network configuration
network --bootproto=dhcp --device=eth0
# Authentication
auth --useshadow --passalgo=sha512
rootpw --iscrypted $6$encryptedpassword
# Timezone
timezone America/New_York
# Partitioning
clearpart --all --initlabel
part /boot --fstype=xfs --size=1024
part swap --size=2048
part / --fstype=xfs --grow --size=1
# Bootloader
bootloader --location=mbr
# Package selection
%packages
@core
@base
wget
vim
%end
# Post-installation script
%post
systemctl enable sshd
useradd -m admin
echo "admin:password" | chpasswd
%end
Key Configuration Sections
Installation Source
url --url="ftp://192.168.200.50/centos7"
System Settings
lang en_US.UTF-8
keyboard us
firewall --disabled
Network Configuration
network --bootproto=dhcp --device=eth0
Partitioning Scheme
clearpart --all --initlabel
part / --fstype=xfs --grow --size=1
part swap --size=2048
Package Selection
%packages
@core
@base
%end
Post-Installation Script
%post
echo "Configuration complete" > /root/install.log
%end
Deployment Process
- Create Kickstart configuration file
- Place file on accessible server (HTTP/FTP)
- Configure boot parameters to reference Kickstart file
- System automatically installs using configuration
This approach provides consistent, repeatable deployments across multiple systems, significantly reducing manual setup time and potential configuration errors.