box.matto.nl

home/

Boot Raspberry Pi with rootfs on NFS

Last edited

Rapsberry Pi

The Raspberry Pi is a very cheap small board with a 700 MHz Arm11 SoC. Buy only the B-model, because this one has a network interface. The A-model comes without network, which makes it much less fun and useable.

To run the Raspberry Pi you will also need:

  • Powersupply: 5V (700mA .. 1100 mA) with micro-USB connector
  • MicroSD card 2 Gb or more

The Raspberry Pi is configured to boot from the MicroSD card. Writing to a MicroSD card wares the card out and also is slow.

So, in order to play with the Raspberry Pi, we first need to move the root filesystem away from the MicroSD card and put it on a NFS server.

Prepare NFS rootfilesystem

  • Create a NFS directory on your NFS server
  • Add this directory to your /etc/exports
  • Reload /etc/exports with exportfs -rv

Mount the NFS directory from the Raspberry Pi and copy the root filesystem to it

  • Start rpcbind and nfs-common with "/etc/init.d/rpcbind start" and "/etc/init.d/nfs-common start"
  • Mount the remote NFS directory to /mnt
  • Copy the root filesystem to /mnt

    cp -axv /. /mnt/.
    cp -axv /dev/. /mnt/dev/.

Edit /etc/fstab on the NFS mount

  • Delete the line which mounts /dev/mmcblk0p2 on / or comment this line out

My /etc/fstab on the NFS mount looks like this:

proc            /proc           proc    defaults 0 0
/dev/mmcblk0p1  /boot           vfat    defaults 0 0
none            /tmp            tmpfs   defaults 0 0
none            /var/run        tmpfs   defaults 0 0
none            /var/lock       tmpfs   defaults 0 0
none            /var/tmp        tmpfs   defaults 0 0

Edit /boot/cmdline.txt

Edit the file /boot/cmdline.txt (it is on the /dev/mmcblk0p1) and change:

  • root=/dev/nfs
  • rootfstype=nfs

and add:

  • nfsroot=192.168.1.1:/nfs/rootfs/raspberry
  • ip=192.168.1.3:192.168.1.1:192.168.1.254:255.255.255.0

to the commandline.

In this example 192.168.1.1 is the ip number of the NFS server and 192.168.1.3 is the ip number of the Raspberry Pi, 255.255.255.0 is the netmask. The directory on the NFS server with the root filesystem is in this example: /nfs/rootfs/raspberry

Reboot

Reboot and have fun!