Install PXE server on Raspberry Pi 4

This approach works fine for Legacy (BIOS) PXE Boot. But UEFI PXE Boot appeared to be an advanced topic. Get ready to dive deep.

To setup a PXE Server we will need the following dependencies:

  • dnsmasq

  • NFS

Network boot is possible due to TFTP. Usually TFTP server has the same IP address as DHCP server, but we will use dnsmasq to configure some kind of relay for our goal. It is called proxy DHCP to be more precise. This way our setup will work in any local network even with grandma's router.

We will setup a NFS (Network File System) server, which will allow computers to access files on PXE server over the network. Using TFTP the client only receives crucial parts of the system important to load, like kernel and initramfs, but the rest files like other additional software and user files will stay on the server, though the client will see these files locally, but all magic is done by NFS.

Note: This tutorial assumes you are the root user, if not, please add sudo for all the commands.

Install and configure

The following command will install required packages on Raspberry OS:

Once downloading is complete, stop the dnsmasq for now

PXELINUX

Create directory where all transferable operating system files will reside

Take important boot modules (pxelinux.0, ldlinux.c32, libutil.c32, menu.c32, poweroff.c32, reboot.c32 and vesamenu.c32) and place them into /srv/tftpboot

Create directory for the PXE configuration file.

Prepare boot menu design

with this content

And styles separately

And the background /srv/tftpboot/pxelinux.cfg/logo.png

logo.png

Check PXELINUX configuration syntax here: https://wiki.syslinux.org/wiki/index.php?title=Config

We will add real entries in the Test section.

dnsmasq

Update the content of /etc/dnsmasq.conf. By default this file full of comments above each option. You can read through and tweak settings to your liking (online manpages), but I already know what I put into:

Add the following line to the /etc/default/dnsmasq file

NFS

In order to give access to specific files to NFS clients add the following line to the /etc/exports file

In case you add Linux systems to /srv/tftpboot using symlinks, you need to add its real path to /etc/exports as well. For example you have symlink /srv/tftpboot/kali -> /media/external_hdd/kali, then add

Then make this change live:

Test

For tests we are going to run Kali Linux and custom Buildroot build (here can be another article about it, but here we'll assume that you already have output/images/rootfs.tar.gz)

Kali

Download an ISO image from official website and transfer it to Raspberry Pi (when I was writing this tutorial the last version was 2021.2 and ISO name correspondingly kali-linux-2021.2-live-amd64.iso)

Then extract it to /srv/tftpboot/kali

Add to boot menu an entry

Buildroot

Do not forget to enable in kernel configuration

  • CONFIG_IP_PNP_DHCP=y

  • NFS filesystem support (CONFIG_NFS_FS).

  • Root file system on NFS (CONFIG_ROOT_NFS).

Transfer rootfs archive to Raspberry Pi

Then extract it to /srv/tftpboot/buildroot

Add to boot menu an entry

Last updated

Was this helpful?