Skip to content

How to set up a NFS root filesystem for embedded Linux development

Although ssh and friends work really well for embedded systems, occasionally you want to set up a NFS root for development.  One of the scenarios where nfsroot is useful is if you are making a lot of rootfs changes, and you don’t want to spend the time to reprogram the flash on the target system.  Fortunately, the Linux kernel includes complete support for NFS root, and does not require any userspace changes.  This setup assumes the following:

  1. the target system has Ethernet support built into the kernel
  2. the target system is on the same network as a Linux workstation
  3. said network includes a DHCP server

This configuration emphasises “simple” and does not require you to spend 4 hours trying to get a bootp server configured on a test network.

Kernel Support

Make sure you have the following options turned on in the kernel:

  • CONFIG_IP_PNP_DHCP=y
  • CONFIG_ROOT_NFS=y

Then, add the following to your kernel CMDLINE:

  • ip=dhcp root=/dev/nfs nfsroot=<nfs server IP>:/path/to/nfsroot

Workstation Setup

The following setup is for Ubuntu.

apt-get install nfs-user-server

(edit /etc/exports to contain something like the following)

/path/to/nfsroot 192.168.1.0/255.255.255.0(no_root_squash,sync,rw)

/etc/init.d/nfs-user-server restart

If you are using OpenEmbedded, then instruct OE to generate a rootfs tar image, and extract to your nfsroot directory:

cd /path/to/nfsroot
sudo tar -xvf <path to OE images dir>/Angstrom-image...rootfs.tar

And the result

eth0: link up, 100Mbps, full-duplex, lpa 0xC5E1
Sending DHCP requests ., OK
IP-Config: Got DHCP answer from 192.168.1.1, my address is 192.168.1.112
IP-Config: Complete:
     device=eth0, addr=192.168.1.112, mask=255.255.255.0, gw=192.168.1.1,
     host=192.168.1.112, domain=hq.bec-systems.com, nis-domain=(none),
     bootserver=192.168.1.1, rootserver=192.168.1.11, rootpath=
Looking up port of RPC 100003/2 on 192.168.1.11
Looking up port of RPC 100005/1 on 192.168.1.11
VFS: Mounted root (nfs filesystem) readonly.
Freeing unused kernel memory: 220k freed
Write protecting the kernel text: 2792k
Write protecting the kernel read-only data: 788k
INIT: version 2.86 booting