Netbooting Raspberry Pi with NFS root
How set up a Raspberry Pi for network boot without local storage and run
it with NFS root filesystem. This should mostly be somewhat universal
across Raspberry Pi 3 & 4, but the local "make it netboot" prep is
different between Pi 3 & Pi 4 and this is mostly about Raspberry Pi 4.
preconditions
We need:
- A Raspberry Pi 4 (duh!) with a running Raspbian installation.
- A machine to serve as NFS, TFTP & DHCP server
- Said machine already set up as NFS, TFTP & DHCP server
preparing the Pi
- You may need to update the bootloader, so run
rpi-eeprom-update -a and reboot the Pi
- enable network boot by running rpi-eeprom-config -e and
setting BOOT_ORDER=0xf21. Note that this has the divergent procedure for Raspberry Pi 3.
- Grab the ethernet address of the ethernet interface from the output
of ip link show.
- Grab the last 8 digits of the serial number from the output of
cat /proc/cpuinfo |grep Serial.
DHCP
We're assuming isc-dhcp-server here.
- Add a standard host entry for the Pi here, using the ethernet
address we extracted before.
- To that host entry, add the following lines:
- TFTP server name: option tftp-server-name "tftp-server";
- NFS root path: option root-path "/nfsroots/raspi-box";
NFS server
- Create a directory /nfsroots/raspi-box and copy the filesystem
from Raspberry Pi there, including /boot.
- Add an entry for it to /etc/exports and reload that config.
TFTP server
Let's go!
Now shutdown your Raspberry Pi, remove power and SD-card and plug in the power
again. It should now boot via the network and mount its root filesystem via
NFS.
Last modified 2024-03-10 by Alexander Schreiber