Skip to content

Diskless Linux Boot via PXE + NFS (Ubuntu / Rocky / Red Hat)

In data centers, cluster environments, educational labs, or large-scale node deployments, Diskless Boot is a common and efficient way to start systems. By combining PXE (Preboot eXecution Environment) with an NFS root filesystem (rootfs), clients can boot Linux without a local disk. This not only reduces hardware costs but also facilitates centralized management and unified system updates.

This article introduces how to use PXE + NFS to provide diskless boot capabilities for Ubuntu, Rocky Linux, and Red Hat Enterprise Linux, covering necessary service configurations, root filesystem preparation, and the client boot process.

1. Architecture (PXE + NFS)

Diskless booting involves three key stages:

1.1 DHCP Stage: Boot Information Delivery

The DHCP server returns the following to the client:

  • TFTP Server Address (next-server)
  • Boot Filename (pxelinux.0 or shim/grubx64.efi)

1.2 TFTP Stage: Loading Kernel and initramfs

The client downloads:

  • Linux Kernel (vmlinuz)
  • initramfs (initrd.img)
  • Bootloader (pxelinux/grub)

1.3 NFS Stage: Mounting Root Filesystem

Scripts inside initramfs execute:

  • Mount the NFS root filesystem
  • Switch to the root filesystem and start the OS

Architecture Diagram:

[PXE Client] → DHCP Server → TFTP Server → Kernel/initrd → NFS Root

2. Environment Example

Using a single server as the unified PXE + NFS provider:

ComponentExample
PXE/NFS Server10.0.0.1
ClientDHCP Auto-assigned
Linux DistroUbuntu / Rocky / RHEL

Directory Structure:

bash
/srv/tftpboot/       # TFTP files
/srv/nfsroot/ubuntu  # Rootfs for each distro
/srv/nfsroot/rocky
/srv/nfsroot/rhel

3. Configure DHCP (ISC DHCP / dnsmasq)

Suitable for lightweight PXE environments.

Install:

bash
sudo apt install dnsmasq

Configure /etc/dnsmasq.conf:

ini
port=0
dhcp-range=10.0.0.50,10.0.0.150,12h

# PXE boot file
dhcp-boot=pxelinux.0,pxeserver,10.0.0.1

# TFTP Service
enable-tftp
tftp-root=/srv/tftpboot

Restart:

bash
sudo systemctl restart dnsmasq

4. Configure TFTP and Prepare PXE Boot Files

Install TFTP Service:

bash
sudo apt install tftpd-hpa pxelinux syslinux-common

Ensure directories exist:

bash
sudo mkdir -p /srv/tftpboot/pxelinux.cfg

Copy boot files:

bash
cp /usr/lib/PXELINUX/pxelinux.0 /srv/tftpboot/
cp /usr/lib/syslinux/modules/bios/* /srv/tftpboot/

5. Prepare Kernel and initramfs

For Ubuntu:

bash
mkdir -p /srv/tftpboot/ubuntu
cp /boot/vmlinuz-$(uname -r) /srv/tftpboot/ubuntu/
cp /boot/initrd.img-$(uname -r) /srv/tftpboot/ubuntu/

For RHEL/Rocky:

bash
cp /boot/vmlinuz-<version> /srv/tftpboot/rocky/
cp /boot/initramfs-<version>.img /srv/tftpboot/rocky/

6. Configure NFS Service

Install NFS:

bash
sudo apt install nfs-kernel-server

Export Root Directories:

bash
/srv/nfsroot/ubuntu *(rw,no_root_squash,no_subtree_check)
/srv/nfsroot/rocky  *(rw,no_root_squash,no_subtree_check)
/srv/nfsroot/rhel   *(rw,no_root_squash,no_subtree_check)

Apply Configuration:

bash
sudo exportfs -a

7. Build Diskless Root Filesystem (rootfs)

7.1 Ubuntu (via debootstrap)

bash
sudo debootstrap focal /srv/nfsroot/ubuntu http://archive.ubuntu.com/ubuntu/

Required Configuration:

bash
echo "ubuntu-client" > /srv/nfsroot/ubuntu/etc/hostname
echo "127.0.1.1 ubuntu-client" >> /srv/nfsroot/ubuntu/etc/hosts

7.2 Rocky / RHEL (via dnf --installroot)

bash
sudo dnf --releasever=9 --installroot=/srv/nfsroot/rocky groupinstall "Minimal Install"

8. Configure PXE Boot Menu

Edit /srv/tftpboot/pxelinux.cfg/default:

text
DEFAULT menu.c32
PROMPT 0
TIMEOUT 50

LABEL Ubuntu Diskless
    KERNEL ubuntu/vmlinuz
    APPEND initrd=ubuntu/initrd.img root=/dev/nfs ip=dhcp nfsroot=10.0.0.1:/srv/nfsroot/ubuntu rw

LABEL Rocky Diskless
    KERNEL rocky/vmlinuz
    APPEND initrd=rocky/initramfs.img root=/dev/nfs ip=dhcp nfsroot=10.0.0.1:/srv/nfsroot/rocky rw

9. Client Boot Verification

Enable PXE in BIOS/UEFI:

  • Intel: Network Boot
  • ARM: PXE over IPv4

Boot Process:

  1. DHCP acquires IP.
  2. pxelinux.0 is downloaded via TFTP.
  3. Kernel and initrd are loaded.
  4. NFS root is mounted.
  5. System entry.

Verify via Server Logs:

DHCP:

bash
journalctl -u dnsmasq

NFS:

bash
journalctl -u nfs-server

10. Troubleshooting

IssueCauseSolution
PXE-T01: File not foundTFTP path errorCheck tftp-root and filenames.
Kernel panic: unable to mount rootfsNFS config errorVerify nfsroot params and exportfs settings.
DHCP TimeoutDHCP service invalidDisable other DHCP servers, check firewall.

11. Summary

Using PXE + NFS for diskless Linux booting significantly reduces node costs, improves environment consistency, and simplifies batch deployment. The examples in this article are based on Ubuntu, Rocky, and Red Hat, but other distributions can be implemented in a similar manner.

AI-HPC Organization