NFS root filesystem
This howto aids you in setting up the neccessary things for network booting FreeWRT.
Prerequisites
What you need:
- FreeWRT RootFS
- A netboot enabled kernel
- TFTP Server
- NFS Server
- DHCP Server
RootFS and Kernel
Getting them is a piece of cake. Just run menuconfig of the FreeWRT buildroot and inside Target system for Target Firmware type choose root filesystem via NFS.
After running make if everything went fine, you should find a tarball containing both rootfs and kernel inside the bin-directory.
After extracting you still have to run instprep-rb.sh found in the top level directory inside the rootfs as root to create the necessary device nodes for booting.
TFTP Server
The TFTP server is used to send the kernel to a booting client. As it's configuration is fairly easy, I won't go into detail here. (Normally it should be enough to start the server with the kernel image's path as argument.)
NFS Server
As the rootfs is to be mounted via NFS, it must be exported to clients. The examples below show how to export the path read-writeable. If you prefer a read-only rootfs, just omit the ro and no_root_squash options.
For exporting, a command like the following should suffice:
# exportfs -o rw,no_root_squash <client-ip>:/path/2/da/rootfs
You can verify this via:
# exportfs -v
Alternatively you can add an entry to /etc/exports, of course. After adding a line like the following:
/path/2/the/rootfs <clientip>(rw,no_root_squash)
run this command:
# exportfs -r
to re-export all filesystems specified in /etc/exports. You can verify it via:
# exportfs -v
DHCP Server
This is the most tricky part, as nearly the complete behaviour of the client is controlled via DHCP. I use the ISC DHCPD version 3, so all samples should be at least working with it, but other DHCP servers can be used as well. Let's begin with a sample configuration I will explain afterwards:
default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
authoritative;
subnet 10.23.42.0 netmask 255.255.255.0 {
range 10.23.42.200 10.23.42.250;
option routers 10.23.42.1;
host rb500 {
hardware ethernet 00:0c:42:06:26:f9;
next-server 10.23.42.1;
fixed-address 10.23.42.223;
filename "kernel";
option root-path "/path/2/the/rootfs";
}
}
The first four statements are quite common ones, you can read about their meanings in the related documentation (i.e. dhcpd.conf manpage, etc).
option routers is crucial as it also defines the NFS server to be used. It is adviceable to create an own subnet definition for each netboot client, as the definition of a fixed address is only possible this way.
The option filename defines the name of the kernel image to be gained via TFTP.
Option root-path must aim to a NFS-exported rootfs. You can also use %s inside the pathstring, which will be expanded to the string representation of the client's IP address.
TFTP Client on Netgear's WGT634U
Since the WGT634U's bootloader (CFE) does not understand the filename option, but has TFTP client support you can set up the location of your netkernel manually in the CFE setup shell. You will need a serial console to perform this.
- Press <Ctrl>+c while power on your router to enter the CFE shell.
- Try to boot the kernel manually (10.23.42.1 is the TFTP server's IP as defined above - you can use a host name, too):
ifconfig eth0 -auto;boot -elf -tftp 10.23.42.1:vmlinux
- If everything went correctly, you can change the STARTUP variable of your WGT634U (the item "boot -elf flash0.os:" provides to boot from flash, if tftp fails):
setenv -p STARTUP "ifconfig eth0 -auto;boot -elf -tftp 10.23.42.1:vmlinux;boot -elf flash0.os:"
Troubleshooting typical problems
- Use tcpdump to analyze network traffic.
- You can get a list of open ports on your system using netstat. The state of a certain port is a good indicator for the status of a daemon binding to this port.
- For RPC to work, a simple daemon called portmap is needed. NFS is a classical RPC application, so it needs portmap, too. Use rpcinfo -v to get a list of RPC applications and the ports they are listening on.
- Sometimes problems with the NFS server are not easy to debug. Test with a client!
- Make sure your TFTP server doesn't run chrooted, and if so, the paths are set up correctly.
- As best create a small private network only containing your computer and the router, so no other daemons (especially DHCPD) can interfere.


