Parallella NFS rootfs Setup

From eLinux.org
Jump to: navigation, search


How-to set up Linaro Nano Root Filesystem for NFS Boot

This Guide describes the steps to extract and prepare Linaro Saucy nano root filesystem to be NFS mounted on the Parallella.
The Guide supports the How-To on setting up TFTP boot and NFS Filesystems, and assumes the same convention (naming, IP Addresses, directories) from that page.
The Guide assumes:

  • The NFS server is a Debian PC environment.
  • A minimal 'headless' nano build. Additional packages may be added as required.
  • A USB-serial cable is connected to the Parallella - at least initially.

The following is derived directly from shodrucky's Linaro Saucy nano build instructions: How-To for setting up a Linaro Nano system. There are some simplifications (less to do setting up the SD Card) and minor modifications (to ensure NFS runs smoothly).

Get the Linaro Saucy nano Image

On the NFS Server, download the Linaro Saucy nano image.

wget http://releases.linaro.org/14.04/ubuntu/saucy-images/nano/linaro-saucy-nano-20140410-652.tar.gz
md5sum linaro-saucy-nano-20140410-652.tar.gz
cded44187fb762ba7ea7b1ee092a0998  linaro-saucy-nano-20140410-652.tar.gz
  • Extract the filesystem image from the download directory into the NFS directory created for the target root filesystem, in this example: /srv/nfs/nano.
sudo tar --strip-components=1 -C /srv/nfs/nano/ -xzpf ~/Downloads/linaro-saucy-nano-20140410-652.tar.gz

Modify Configuration Files

On the NFS Server, edit the following files in the NFS directory.

WARNING! WARNING! WARNING! WARNING! WARNING!

  • Make sure you are in the CORRECT NFS directory - edits are with root (sudo) priviledge!!


  • Prevent installation of unnecessary packages
sudo nano /srv/nfs/nano/etc/apt/apt.conf.d/00InstallRecommends

(Edit and save)

APT::Install-Recommends "false";
  • Edit the network configuration files. The kernel will be instructed to use DHCP in the bootargs provided by U-Boot. The Gigabit Ethernet interface will have been set up during boot, so the interfaces file can be kept simple.
sudo nano /srv/nfs/nano/etc/network/interfaces

(Edit to contain only the following lines, and save)

auto lo
iface lo inet loopback

Set up the nameserver address, as it applies to your network. For example:

sudo nano /srv/nfs/nano/etc/resolv.conf 

(Edit and save)

nameserver 192.168.1.1
  • Edit the root filesystem table to mount temporary files in Parallella RAM. Reduces traffic.
sudo nano /srv/nfs/nano/etc/fstab

(Edit and save)

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/nfs        /               nfs     defaults        1       1
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

Install SSH

To access the Parallella remotely from your PC, add the SSH server package to the nano build.
Any changes to the root filesystem that require maintaining or obtaining new packages need to be run as a session on the Parallella, as root (or by sudo).

  • If the USB Serial cable is connected then there is a root session prompt at the console.
  • If the HDMI build has been booted, and keyboard/screen are available then log on as Linaro and prepend sudo to the following commands.

For this sequence, assume that the console has been enabled in the bootscript This is described in How-To on setting up TFTP boot and NFS Filesystems. Boot up the Parallella and the kernel should boot and eventually display the 'root@linaro' prompt at the UART console. Enter the following:

apt-get update
apt-get install openssh-server xauth

Once successfully updated and SSH installed, shutdown the Parallella.

shutdown -h now

After shutdown, power off the Parallella.

Note: after this sequence, if required, the USB serial cable can be removed, the console argument can be deleted from the bootargs string, and the bootscript rebuilt to boot completely 'headless'.
Now you can login to the Parallella from your PC using SSH.
Power on the Parallella, and wait for a minute or so while the boot sequence completes. (That is, wait for the network activity LEDs to calm down, approximately 30 secs).
On the PC, to connect using SSH to the Parallella, for example, para1, use the IP address, unless 'para1' has been set up in the PC's /etc/hosts file.

ssh linaro@192.168.1.21
password: linaro

Additional Packages and Maintenance

This must be done in a session on the Parallella, either via the UART console or via SSH. For example, to add some recommended packages in an SSH session:

sudo apt-get install fake-hwclock wget less unzip

Other additions such as adding the Epiphany SDK to the build are described in the How-To for setting up a Linaro Nano system.

Disable sshd hostname look-up

To fix slow SSH connections, on the PC Host (in the correct directory!):

sudo nano /srv/nfs/etc/ssh/sshd_config

(add to the bottom of the file)

UseDNS no

Mitigating NFS Timeouts - "Dirty Writes"

Writing across the network will inevitably be slower than direct to disk, and queues may build up as the kernel optimises/caches IO buffers. Some versions of the kernel flush the cache when it reaches a certain level, say, 40%. This may result in longer waits at the application level, and timeouts may occur. For example, the following message may appear after the command apt-get update:

INFO: task apt-get:1587 blocked for more than 20 seconds.
      Not tainted 3.12.0-g0bc9c3a-dirty #6

The level at which the cache is flushed can be set lower at, say, 5% or even as low as 1% (so treat as a "tuning opportunity").
On the NFS server, edit the Parallella NFS root filesystem (i.e. the NFS Client) to adjust the "dirty_ratio" parameter as follows:

sudo nano /srv/nfs/nano/etc/sysctl.conf

(Edit to add the following lines at the end of the file, and save)

vm.dirty_background_ratio = 5
vm.dirty_ratio = 5

Note: this may not be required on newer kernels, or in all cases.


Back-up/Copy the Root Filesystem

At some stage, the root filsystem will be configured as required.
Copy (perhaps to a spare SD card?) or back-up the NFS directory so that it can be restored at a later time.