Setting up TFTP and NFS

From PlugWiki

Jump to: navigation, search

Contents

Links to TFTP and NFS Server Configuration for Diskless Boot Devices

First, there are some excellent tutorials on setting up Diskless devices using TFTP to download the Linux (or BSD) kernel and then mounting a root file system using the kernel's NFS client support to mount the root filesystem (ie., "/"). The list below starts with some of our favorites at the top, but all the links are useful depending on the operating system you select for your TFTP and NFS server.

  * NetBSD Diskless Boot TFTP Server Setup Guide
  * NetBSD Diskless Boot NFS Server Setup Guide

Setting Up a TFTP Server

The first thing one needs of course, is a Linux kernel suitable for the Marvel Kirkwood Plug Computer, which you can make or download from this page: Compiling Linux Kernel for the Plug Computer.

TFTP Server Configuration on Ubuntu Jaunty

One configuration for a TFTP server is using the Ubuntu tftpd-hpa package.

TFTP Server Configuration on Gentoo

Getting a Pre-Built Linux Kernel for the TFTP Server

However, you can just go and get a Linux kernel and NFS root file system and download them.

Gentoo NFS Root File System

Here is an example based on Gentoo with a SELinux-enabled Linux kernel as a base, SELinux Plug Computer Gentoo Distribution. There is also a much larger Baseline Gentoo you can use as a NFS root file system as well that has all the development ability put back into it without going through the steps of updating the SELinux Plug Computer Gentoo Distribution.

U-Boot Configuration for a TFTP and NFS Server Boot Sequence

Now, setup U-Boot to have a configuration, at least, similar to the environment printed below from a working Plug Computer.

Hit any key to stop autoboot: 0
Marvell>> print
baudrate=115200
loads_echo=0
netmask=255.255.255.0
CASset=min
MALLOC_len=1
ethprime=egiga0
bootargs_root=root=/dev/nfs rw
bootargs_end=:::DB88FXX81:eth0:none
bootcmd=tftpboot 0x2000000 $(image_name);setenv bootargs $(console) $(bootargs_root) nfsroot=$(serverip):$(rootpath) ip=$(ipaddr):$(serverip)$(bootargs_end) $(mvNetConfig) $(mvPhoneConfig); bootm 0x2000000;
standalone=fsload 0x2000000 $(image_name);setenv bootargs $(console) root=/dev/mtdblock0 rw ip=$(ipaddr):$(serverip)$(bootargs_end) $(mvPhoneConfig); bootm 0x2000000;
ethmtu=1500
mvPhoneConfig=mv_phone_config=dev0:fxs,dev1:fxs
mvNetConfig=mv_net_config=(00:11:88:0f:62:81,0:1:2:3),mtu=1500
usb0Mode=host
yuk_ethaddr=00:00:00:EE:51:81
nandEcc=1bit
netretry=no
rcvrip=169.254.100.100
loadaddr=0x02000000
autoload=no
console=console=ttyS0,115200 mtdparts=cfi_flash:0xf40000(root),0xc0000(uboot)ro
ethaddr=00:50:43:3c:3b:6e
image_name=uImage.4mini
ethact=egiga0
bootargs=console=ttyS0,115200 mtdparts=cfi_flash:0xf40000(root),0xc0000(uboot)ro root=/dev/nfs rw nfsroot=10.50.100.100:/usr/src/marvell/marvell_builds/sheevaplug/gentoo_sheevamini_256M_selinux ip=10.50.100.22:10.50.100.100:::DB88FXX81:eth0:none
mv_net_config=(00:11:88:0f:62:81,0:1:2:3),mtu=1500 mv_phone_config=dev0:fxs,dev1:fxs
ipaddr=172.20.10.22
serverip=172.20.10.55
rootpath=/mnt/share/nfsroot/gentoo_sheevamini_256M_selinux
stdin=serial
stdout=serial
stderr=serial
mainlineLinux=no
enaMonExt=no
enaCpuStream=no
enaWrAllo=no
pexMode=RC
disL2Cache=no
setL2CacheWT=yes
disL2Prefetch=yes
enaICPref=yes
enaDCPref=yes
sata_dma_mode=yes
netbsd_en=no
vxworks_en=no
bootdelay=3
disaMvPnp=no
enaAutoRecovery=yes
Environment size: 1635/131068 bytes

Now, the one you probably want to change are the following:

  * rootpath (based on your NFS /etc/exports file)
  * serverip (based on your TFTP and NFS server IP address)
  * ipaddr (the IP address in the same subnet as your TFTP and NFS server IP address)

NFS Root File System Notes for Each Distribution

Ubuntu as NFS Root File System

After you get a tar ball of the Ubuntu Jaunty root file system to put on your NFS server to export, it is worth doing the following check or configuration changes to make sure the Plug Computer will boot to the point where you can ssh to the system.

Change the Default DHCP Configuration to Static IP Address on the Plug

Since the Ubuntu Jaunty 9.04 SheevaPlug distribution defaults to DHCP, the init script, networking, stops the boot process if the file system is taken "as is" from the Marvell SheevaPlug website. The configuration file, /etc/network/interfaces, can be changed to match the static IP address from the u-boot configuration (see above) so the init script does not hang the NFS root boot process. Assuming the IP addresses from the u-boot environmental variables is correct above (e.g., 172.20.10.22 and a gateway of 12.20.10.1), you can set /etc/network/interfaces file to contain the following variables and to a static IP address:

  * auto eth0
  * iface eth0 inet static
  * address 172.20.10.22
  * netmask 255.255.255.0
  * gateway 172.20.10.1
Generate New SSH Server Host Keys for the Plug

You will probably want to generate new SSH server host keys if either the Jaunty NFS Root file system has old or no SSH server host keys. You can run the following commands from the serial console connection if you cannot connect via SSH the first time. You can also generate the keys from the NFS server if you cannot get serial console access.

  * ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key (over-write the old keys and do NOT set a passphrase)
  * ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key (ditto to above notes)
  * /etc/init.d/ssh restart

You should now be able to use a ssh client to get to the NFS root file system.

New Plugger HOWTO

After doing the repository update described below, but before rebooting, please read the section about update issues with udev below this section.

Now go to the New Plugger HOWTO and update your Ubuntu Jaunty NFS Root File System with the recommendation to /etc/rc.local found there.

Since we are using a static IP address, the dhclient.conf file recommendations from the New Plugger HOWTO do not apply here since we want the static IP address assigned to the SheevaPlug by u-boot, but it is not a bad idea to make the change since you may generate a root file system for UBIFS support from this NFS Root File System.

Udev Package Upgrade Saftey Step on the Plug

After doing the New Plugger HOWTO steps described above, you might see a failure from the udev package update. It could be due to an incorrect configuration of the NFS root file system or how it was prepared with tar, but there is an issue that might occur if the post-install script of udev fails. The issue is the random number generation device interfaces, /dev/random and /dev/urandom, are not created by udev. This results in many things failing upon reboot including your SSH server. Thus, as a backup step, you can create the devices in /lib/udev/devices just in case the udev package update fails when doing the "apt-get dist-upgrade" step from the New Plugger HOWTO. This step can be done on the NFS server root file system where </nfsroot/location/> is the NFS export directory on your NFS server if you don't have a serial console.

  * mknod </nfsroot/location/>/lib/udev/devices/random c 8 1
  * chmod 0666 </nfsroot/location/>/lib/udev/devices/random
  * mknod </nfsroot/location/>/lib/udev/devices/urandom c 9 1
  * chmod 0666 mknod </nfsroot/location/>/lib/udev/devices/urandom

After rebooting and logging in via a ssh client, you can stop the udev daemon and reinstall the udev package with apt-get and not see the same failure.

  * /etc/init.d/udev stop
  * apt-get install --reinstall udev

Gentoo as NFS Root File System

Personal tools