NFS booting and the Readynas 1022014-01-18
The Netgear ReadyNas 102 is a cheap NAS for home use, and it’s actually really hacker friendly!
Serial port pins accessible from the back of the case
Good upstream Linux support for the Marvell Armada 370 SOC U-boot At Arnos site You can get all information about the NAS there.
These instructions on how to boot the NAS with nfs root, is based on his work! So you should read his instructions to get the general idea on how to setup tftp and booting the NAS and then come back here for instructions on how to setup boot with nfsroot.
Using a root filesystem mounted over NFS can be really useful when developing for embedded system. In this case my motivation was to try to see if I could boot an Arch Linux rootfs before actually trying to install Arch Linux on the NAS. It worked and hopefully the next post will be about installing Arch Linux on the NAS.
Adding nfsroot support to the Linux kernel Before building the Linux kernel you will need to enable support for nfsroot. And to run Arch Linux that uses systemd as /sbin/init cgroups needs to be enabled as well. The diff between my and Arnos kernel configs can be seen below.
Add the config options and build the kernel according to Arnos instructions.
--- kernelconfig-arno 2013-09-22 01:07:24.000000000 +0200 +++ kernelconfig-nfsroot-and-cgroups 2014-01-18 18:37:06.615290810 +0100 @@ -91,7 +91,15 @@ CONFIG_IKCONFIG_PROC=y CONFIG_LOG_BUF_SHIFT=18 CONFIG_GENERIC_SCHED_CLOCK=y -# CONFIG_CGROUPS is not set +CONFIG_CGROUPS=y +# CONFIG_CGROUP_DEBUG is not set +# CONFIG_CGROUP_FREEZER is not set +# CONFIG_CGROUP_DEVICE is not set +# CONFIG_CPUSETS is not set +# CONFIG_CGROUP_CPUACCT is not set +# CONFIG_RESOURCE_COUNTERS is not set +# CONFIG_CGROUP_SCHED is not set +# CONFIG_BLK_CGROUP is not set # CONFIG_CHECKPOINT_RESTORE is not set # CONFIG_NAMESPACES is not set CONFIG_UIDGID_CONVERTED=y @@ -521,7 +529,10 @@ CONFIG_IP_MULTIPLE_TABLES=y # CONFIG_IP_ROUTE_MULTIPATH is not set # CONFIG_IP_ROUTE_VERBOSE is not set -# CONFIG_IP_PNP is not set +CONFIG_IP_PNP=y +CONFIG_IP_PNP_DHCP=y +# CONFIG_IP_PNP_BOOTP is not set +# CONFIG_IP_PNP_RARP is not set CONFIG_NET_IPIP=y # CONFIG_NET_IPGRE_DEMUX is not set CONFIG_NET_IP_TUNNEL=y @@ -749,6 +760,7 @@ # CONFIG_NETLINK_MMAP is not set # CONFIG_NETLINK_DIAG is not set # CONFIG_NET_MPLS_GSO is not set +# CONFIG_NETPRIO_CGROUP is not set CONFIG_NET_RX_BUSY_POLL=y CONFIG_BQL=y # CONFIG_BPF_JIT is not set @@ -2497,6 +2509,7 @@ CONFIG_NFS_V4=y # CONFIG_NFS_SWAP is not set # CONFIG_NFS_V4_1 is not set +CONFIG_ROOT_NFS=y # CONFIG_NFS_FSCACHE is not set # CONFIG_NFS_USE_LEGACY_DNS is not set CONFIG_NFS_USE_KERNEL_DNS=y
Obtaining and setting up the root filesystem
I used the filesystem for the Mirabox as a basis, but any filesystem with sane defaults could be used. Download the rootfs from http://archlinuxarm.org/platforms/armv7/marvell/mirabox unpack it as root (to get the permissions right) under some dir (I use /srv/nfs/rootfs in the example).
As the Mirabox is expecting a boot-partition on /dev/sdb1 you should comment that mount out in the etc/fstab file in the file system. Otherwise systemd will complain on startup. And while your at it, edit etc/resolv.conf to get name resolution working on your NAS as well.
Add the filesystem path to your /etc/export. The following setting works for me:
Booting the kernel with the root file system on NFS Use Arnos instruction to transfer the newly built kernel to memory while in u-boot. On my NAS neither of the serverip or ipaddr environment variables was set. Set them and load the kernel with:
set serverip 192.168.1.141; set ipaddr 192.168.1.10; tftpboot 1200000 uImage
In my setup the NFS-server is on ip-address 192.168.1.141 and the the NAS uses the IP-address 192.168.1.10
When bootm is executed U-boot reads the bootargs environment variable. This is where the command line arguments that is passed on to the kernel is set. Below is an example of a kernel command line.
setenv bootargs root=/dev/nfs rw nfsroot=192.168.1.141:/srv/nfs/rootfs,v3 ip=192.168.1.10:192.168.1.141:192.168.1.1:255.255.0.0:readynas::off console=ttyS0,115200 earlyprintk nfsrootdebug
Read more about Linux and nfsroot here.
Now boot the NAS with the command bootm 1200000 and the kernel should boot and mount the nfs directory as the root filesystem. You could continue to use the serial console or try to ssh to the NAS with root:root.