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:
- the target system has Ethernet support built into the kernel
- the target system is on the same network as a Linux workstation
- 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.
Make sure you have the following options turned on in the kernel:
Then, add the following to your kernel CMDLINE:
ip=dhcp root=/dev/nfs nfsroot=<nfs server IP>:/path/to/nfsroot
The following setup is for Ubuntu.
apt-get install nfs-user-server
(edit /etc/exports to contain something like the following)
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