Setting Up an Arch PXE Server - a straightforward way

What is a PXE Server

A PXE (Preboot Execution Environment) server allows client machines to boot a complete operating system from the network without any local storage. This is particularly useful for diskless workstations, automated installations, or testing multiple systems consistently from a central server. Using Arch Linux for a PXE server provides a lightweight, flexible, and highly customizable environment, ideal for IT labs, data centers, or home labs where you want to quickly boot and manage multiple machines.


1. Download Arch Linux ISO and Install Required Packages

Download the Arch Linux ISO from the official site: https://archlinux.org/download/. Then mount it to /srv/archlinux:

sudo mkdir -p /srv/archlinux
sudo mount --mkdir -o loop,ro archlinux-release_date-x86_64.iso /srv/archlinux

Then install the necessary packages for pxe boot.

sudo pacman -S dhcp nfs-utils syslinux tftp-hpa

These packages provide: DHCP for IP assignment, NFS for sharing files, TFTP for initial boot files, and Syslinux as the bootloader.

2. Configure DHCP Server

Edit the DHCP configuration file at /etc/dhcpd.conf to define the PXE boot parameters. Replace 192.168.144.1 with your PXE server’s IP:

subnet 192.168.144.0 netmask 255.255.255.0 {
  range 192.168.144.101 192.168.144.200;
  option routers 192.168.144.1;
  option domain-name-servers 8.8.8.8, 8.8.4.4;
  filename "lpxelinux.0";
  next-server 192.168.144.1;#replace with your server IP
}

This configuration tells client machines where to find the PXE bootloader when they request a network boot.

3. Prepare TFTP Directory

Create the TFTP directory and copy the required bootloader and kernel files. These files will be served to clients during network boot:

sudo mkdir -p /srv/tftp/pxelinux.cfg
sudo cp /srv/archlinux/arch/boot/x86_64/vmlinuz-linux /srv/tftp/
sudo cp /srv/archlinux/arch/boot/x86_64/initramfs-linux.img /srv/tftp/
sudo cp /srv/archlinux/boot/syslinux/ldlinux.c32 /srv/tftp/
sudo cp /srv/archlinux/boot/syslinux/lpxelinux.0 /srv/tftp/

Next, create the PXE boot menu file /srv/tftp/pxelinux.cfg/default with the following content. Replace the archiso_nfs_server IP with your server IP:

DEFAULT linux
PROMPT 0
TIMEOUT 50

LABEL linux
    MENU LABEL ^Arch Linux NFS
    KERNEL vmlinuz-linux
    APPEND initrd=initramfs-linux.img ip=dhcp archisobasedir=arch archiso_nfs_srv=192.168.144.1:/srv/archlinux cms_verify=y

This configuration tells Syslinux to boot the Arch Linux kernel over NFS using DHCP, and points to the correct NFS share.

Verify TFTP Directory Structure

Check that the files are correctly organized under /srv/tftp:

/srv/tftp
├── initramfs-linux.img
├── lpxelinux.0
├── ldlinux.c32
├── vmlinuz-linux
└── pxelinux.cfg
    └── default

This structure ensures that the PXE bootloader can locate the kernel, initramfs, and boot menu for clients.

4. Configure TFTP Server

Adjust your TFTP configuration to serve files from /srv/tftp. The key is that the bootloader and kernel are accessible to clients on the network. Edit the TFTP configuration file at /etc/conf.d/tftpd to define the PXE boot parameters.

TFTP_DIRECTORY="/srv/tftp"
TFTP_ADDRESS="192.168.144.1:69"
TFTP_OPTIONS=""
TFTPD_ARGS="--user ftpc --address 192.168.144.1:69 --secure /srv/tftp"

5. Share NFS Root Filesystem

Export the mounted Arch Linux ISO via NFS so clients can use it as their root filesystem. Replace the IP range with your network subnet:

/srv/archlinux 192.168.144.0/24(ro,no_subtree_check)  #replace with your subnet

This allows multiple clients to boot from the same central location over the network.

6. Start All Services

Finally, start all required services for PXE boot:

sudo ip link set enp2s0 up  #change if you are using different network interface
sudo ip addr add 192.168.144.1/24 dev enp2s0  
sudo dhcpd -4 -cf /etc/dhcpd.conf enp2s0
sudo systemctl start tftpd
sudo exportfs -rav
sudo systemctl start nfs-server

After starting these services, client machines on your network can boot via PXE using the setup you configured.