Version 1 (modified by amain, 3 years ago) (diff)

--

NFS boot

Originally written to setup the EdgeRouterLite, but below instructions should also provide some pointers how to setup NFS server.

Note that this article uses Ubuntu to run the TFTP and NFS servers.

Setup TFTP Server (DNSMasq)

Replace [IP-DNS-SERVER] with the IP-address of your DNS server. This may be useful if you want to connect the erlite to your network/internet later on.

Copy the DebWrt kernel to /var/lib/tftproot:

cp openwrt-octeon-erlite-vmlinux.64 /var/lib/tftproot/debwrt-firmware-octeon-erlite-vmlinux.64 

Put the following in /etc/dnsmasq.conf.

interface=eth0
bind-interfaces
expand-hosts
domain=thuis.lan
domain-needed
bogus-priv
local=/thuis.lan/
dhcp-range=192.168.1.1,192.168.1.2,12h
dhcp-option=[IP-DNS-SERVER]
dhcp-option=17,/nfs/root
enable-tftp
tftp-root=/var/lib/tftpboot

Restart the DNS server

/etc/init.d/dnsmasq restart

Setup NFS kernel server

Prepare the NFS root filesystem:

mkdir -p /nfs/root
tar xf debwrt-modules-octeon-generic-[kernel-version]-[debwrt-version].tar.gz -C /nfs/root
tar xf debwrt-rootfs-octeon-generic-[kernel-version]-[debwrt-version].tar.gz -C /nfs/root

Setup the NFS export by adding the following line to /etc/exports:

/nfs/root	192.168.1.2(rw,sync,no_subtree_check,no_root_squash)

And restart the kernel server

/etc/init.d/nfs-kernel-server restart

Boot device over NFS

Plugin the serial console, start minicom -w on your PC (after configure it with sudo minicom -s). And power up the erlite. Press CTRL-C to access the U-Boot command line prompt, and type:

setenv nfs 'tftpboot 0 debwrt-firmware-octeon-erlite-vmlinux.64; bootoctlinux 0 coremask=0x3 endbootargs root=/dev/nfs ip=dhcp rw mtdparts=phys_mapped_flash:512k(boot0),512k(boot1),64k@1024k(eeprom)'
saveenv

This creates and save a small U-boot boot script.

Boot over NFS:

run nfs

See NFS bootlog below on how this should look like.

Install DebWrt to USB disk

After successfully booting from NFS, DebWrt can be installed to the internal USB disk.

On the machine running the NFS server, copy DebWrt kernel, rootfs and modules to /nfs/root:

mkdir /nfs/root/debwrt
cp debwrt-firmware-octeon-erlite-vmlinux.64 /nfs/root/debwrt 
cp debwrt-modules-octeon-generic-[kernel-version]-[debwrt-version].tar.gz /nfs/root/debwrt
cp debwrt-rootfs-octeon-generic-[kernel-version]-[debwrt-version].tar.gz /nfs/root/debwrt

Before continuing on the erlite, make sure to make a copy of /dev/sda1 and /dev/sda2, if you every want to move back to use the original Ubiquity software. In the next step we will wipe out /dev/sda2!

On the erlite (booted over NFS):

# Create mount points
mkdir /mnt/boot
mkdir /mnt/rootfs

# Setup clean rootfs on /dev/sda2
mkfs.ext3 /dev/sda2

# Mount
mount /dev/sda1 /mnt/boot
mount /dev/sda2 /mnt/rootfs

# Copy kernel
cp debwrt-firmware-octeon-erlite-vmlinux.64 /mnt/boot

# Extract rootfs
tar xf /debwrt/debwrt-modules-octeon-generic-[kernel-version]-[debwrt-version].tar.gz -C /mnt/rootfs
tar xf /debwrt/debwrt-rootfs-octeon-generic-[kernel-version]-[debwrt-version].tar.gz -C /mnt/rootfs

# Unmount
umount /mnt/boot
umount /mnt/rootfs

Boot from disk

Now reboot the erlite, press CTRL-C again to interrupt U-Boot and type:

setenv disk 'fatload usb 0 $loadaddr debwrt-firmware-octeon-erlite-vmlinux.64; bootoctlinux 0 coremask=0x3 endbootargs root=/dev/sda2 rootdelay=15 rw mtdparts=phys_mapped_flash:512k(boot0),512k(boot1),64k@1024k(eeprom)
nfsq=tftpboot 0 vmlinux.64; bootoctlinux 0 coremask=0x3 endbootargs root=/dev/nfs ip=dhcp rw mtdparts=phys_mapped
_flash:512k(boot0),512k(boot1),64k@1024k(eeprom)'
saveenv

And boot from disk:

run disk

Once everything works out, you can have the erlite boot DebWrt automatically from disk when powering up the erlite or reboot it, by changing the U-Boot bootcmd env variable.

setenv bootcmd 'fatload usb 0 $loadaddr debwrt-firmware-octeon-erlite-vmlinux.64; bootoctlinux 0 coremask=0x3 endbootargs root=/dev/sda2 rootdelay=15 rw mtdparts=phys_mapped_flash:512k(boot0),512k(boot1),64k@1024k(eeprom)
nfsq=tftpboot 0 vmlinux.64; bootoctlinux 0 coremask=0x3 endbootargs root=/dev/nfs ip=dhcp rw mtdparts=phys_mapped
_flash:512k(boot0),512k(boot1),64k@1024k(eeprom)'
saveenv

# reboot erlite
reset