Work in progress ... it works, but incomplete.

NSLU2 - Installing Debian/NSLU2 w/ NFS


Introduction

There are several ways to install linux onto a NSLU2. The OpenWRT/Kamikaze version does not require external storage, but this Debian version expects the rootfs to be mounted via NFS. This set of instructions are my very simple no-frills how-to method compiled from several sources: NSLU2 Linux, Debian/NSLU2, and TWIST.


Server Side - Configuring The Server

Each of these sections have to be completed on the server exporting the rootfs to the NSLU2s.

Networking

Assuming eth0 is connected to the "real world," we will setup eth1 to connect to the Slugs/Motes.

In Debian, add the following to /etc/network/interfaces

auto eth1=mote-lan
iface mote-lan inet static
address 192.168.200.1
netmask 255.255.255.0
broadcast 192.168.200.255
This will make the server, 192.168.200.1, the gateway to mote-lan.

Bring the interface up by issuing ifup eth1=mote-lan at the shell prompt.

Add the following entry to the /etc/hosts file. Be careful when making this entry. The name of the server as seen from eth1 should NOT be the exact same name as the actual server.

192.168.200.1 server2 server2.mote.lan
DNS
Add these entries to /etc/bind/named.conf
        zone "mote.lan" {
              type master;
              file "/export/nslu2/etc/bind/db.mote";
        };

        zone "200.168.192.in-addr.arpa" {
              type master;
              file "/export/nslu2/etc/bind/db.192.168.200";
        };
	
Create these files in the /export/nslu2 workspace on the server for the NSLU2s to use.

/export/nslu2/etc/bind/db.mote

        ;
        ; BIND data file MOTE LAN (forward lookup)
        ;
        $TTL    604800
        @       IN      SOA     mote.lan. root.mote.lan. (
                                      2         ; Serial
                                 604800         ; Refresh
                                  86400         ; Retry
                                2419200         ; Expire
                                 604800 )       ; Negative Cache TTL
        ;
        @       IN      NS      server2.mote.lan.
        ;
        server2  IN      A       192.168.200.1
             
/export/nslu2/etc/bind/db.192.168.200
        ;
        ; BIND data file MOTE LAN (reverse lookup)
        ;
        $TTL    604800
        @       IN      SOA     mote.lan. root.mote.lan. (
                                      2 ;       Serial
                                 604800         ; Refresh
                                  86400         ; Retry
                                2419200         ; Expire
                                 604800 )       ; Negative Cache TTL
        ;
        @       IN      NS      server2.mote.lan.
        ;
        1       IN      PTR     server2.mote.lan.
	
Restart the DNS server
server# /etc/init.d/bind9 restart

DHCP

Add this entry to /etc/dhcp3/dhcpd.conf
        #
        # Setup for the MOTE subnet
        #
        subnet 192.168.200.0 netmask 255.255.255.0 {

               option routers                  192.168.200.1;
               option subnet-mask              255.255.255.0;

               option domain-name              "mote.lan";
               option domain-name-servers      192.168.200.1;

               range dynamic-bootp 192.168.200.100 192.168.200.200;

               default-lease-time 86400;
               max-lease-time 604800;
               ddns-update-style interim;

               # include nslu2 node address assignments
               include "/export/nslu2/etc/dhcp/dhcpd.nslu2.conf";
	}
	
Create the file /export/nslu2/etc/dhcp/dhcpd.nslu2.conf. Enter the information for all the NSLU2s on your network.
        host LKG123456 {
           hardware ethernet 11:22:33:44:55:66;
           fixed-address 192.168.200.10;
           ddns-hostname LKG123456;
        }

        host LKG654321 {
           hardware ethernet 77:88:99:00:11:22;
           fixed-address 192.168.200.11;
           ddns-hostname LKG654321;
        }
     
Restart the dhcp server.
server# /etc/init.d/dhcp3-server restart


NFS

Add these entries to /etc/exports.
   # General Workspace
   /export/nslu2/work\
   192.168.200.0/24(rw,async,no_subtree_check,no_root_squash)

   # ----- NOTE: Each NSLU2 will need a pair of entries here -----

   # NSLU2 root file systems
   /export/nslu2/rootfs/LKG123456\
   192.168.200.10/32(rw,async,no_subtree_check,no_root_squash)

   # NSLU2 swap space
   /export/nslu2/swapfs/LKG123456\
   192.168.200.10/32(rw,async,no_subtree_check,no_root_squash)

   # NSLU2 root file systems
   /export/nslu2/rootfs/LKG654321\
   192.168.200.10/32(rw,async,no_subtree_check,no_root_squash)

   # NSLU2 swap space
   /export/nslu2/swapfs/LKG654321\
   192.168.200.10/32(rw,async,no_subtree_check,no_root_squash)
     
Restart the NFS server.
server# /etc/init.d/nfs-kernel-server restart
SWAP
Create swap space for each of the NSLU2s on your network.
server# cd /export/nslu2/swapfs
server# mkdir LKG123456
server# mkdir LKG654321
server# dd if=/dev/zero of=swapfile bs=1M count=64


rootFS

For the time being, I borrowed the rootfs from the TWIST project. There needs to be a copy for each NSLU2.
server# cd /export/nslu2/rootfs/LKG123456
server# tar xjvf twist_nslu2.tar.bz2


NSLU2 Side - Installing Debian/NSLU2 w/ NFS

First, install upslug2 onto your linux PC. If you are not using linux, please refer to the Debian/NSLU2 website for alternative installation methods.

Installing upslug2 can be as simply as issuing a "apt-get install upslug2" for Debian-based computers. If there are dependency issues, either update the libraries (which may break other programs) or download the source and rebuild it.

% svn co http://svn.nslu2-linux.org/svnroot/upslug2/trunk upslug2
% cd upslug2
% autoreconf -i
% ./configure
% make
If you are using Redhat 5 or later, you can try rpm -ihv http://pion.xs4all.nl/rpm/rhel5-i386/upslug-20070916-1.i386.rpm

Next, retrieve the image, debianslug-3.10-beta.bin, that will be flashed onto the NSLU2. Although there are later versions available, this version has been suggested by the guys at TWIST.

You need to download the SlugOS/LE firmware image of version 3.10 (beta). This image, formerly known as DebianSlug, is compatible with the Debian arm port and can be set up to run with a NFS-exported file system. --TWIST Documentation
If you are interested, all the versions can be found here. Alternative versions can be found here.

To flash the NSLU2, it has to connected to the same network segment as the PC that has the image. The simplest way to ensure it is on the same network segment is to plug your PC and the NSLU2 into a hub.

Place the NSLU2 into upgrade mode by pressing the reset button in with a paperclip or similar object and holding it while turing on the NSLU2. Hold the reset button in until the ready/status light turns red. Release the reset button immediately. The ready/status light should cycle red and green.

From your linux PC, you can issue a upslug2 command without any options to determine if the slug is indeed on the same network segment and is in upgrade mode.

% ./upslug2 -d eth1
NSLU2 00:11:22:33:44:55 Product ID: 1 Protocol ID: 0 Firmware Version: R23V63 [0x2363]
Since the NSLU2 was found, upload the image. DO NOT STOP THIS PROCESS! It will take a few minutes, and stopping this process will create a paperweight.
% ./upslug2 -d eth1 --target="00:11:22:33:44:55" --image="debianslug-3.10-beta.bin"
Upgrading LKG123456 00:11:22:33:44:55
. original flash contents    * packet timed out
! being erased                   - erased
u being upgraded              U upgraded
v being verified                  V verified
Display:
    <status> <address completed>+<bytes transmitted but not completed>
Status:
* timeout occurred             + sequence error detected
7fffff+000000 ...VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
Rebooting... done
When the flashing is finished, the NSLU2 will reboot. You will not be able to access the NSLU2 for a few minutes. Once the NSLU2 has finished rebooting, you can access it using a ssh client. The NSLU2 will try to obtain its IP address using DHCP. If it cannot determine its address through DHCP, it may assign itself to the address stored in the NSLU2 prior to flashing. If no IP address was ever assigned, the NSLU2 will use the factory default address, 192.168.1.77.

ssh to to the NSLU2 using the account root with the password opeNSLUg.

server# ssh root@192.168.200.10
root@192.168.1.77's password:
Host name: LKG123456
...
Use 'turnup init' to reset the configuration
Use 'turnup preserve' to save the configuration permanently
Use 'turnup restore' to restore a previously saved configuration
Use 'turnup disk|nfs -i options to initialise a non-flash root
Use 'turnup help' for more information
LKG123456#
After logging into the NSLU2, it will be necessary to start nfs. A reboot will be necessary for the changes to take hold.
LKG123456# turnup nfs 192.168.200.1:/export/nslu2/rootfs/`hostname`
/sbin/turnup: umounting any existing mount of /dev/mtdblock4
LKG123456# reboot
Log back into the NSLU2 as root. ssh may complain because the host identification has changed. If so, edit your .ssh/known_hosts file. Next, update the file /etc/fstab on the NSLU2.
    # root fs 
    192.168.200.1:/export/nslu2/rootfs/LKG35756D    /       nfs     nolock,noatime,hard,intr,rsize=1024,wsize=1024  1  1

    # swap file
    192.168.200.1:/export/nslu2/swapfs/LKG35756D         /mnt/swap nfs     udp,nolock,noatime,hard,nointr,rsize=32768,wsize=32768,noauto      1  1

    # MOTE backend 
    192.168.200.1:/export/work                  /opt/work      nfs     udp,nolock,noatime,hard,nointr,rsize=32768,wsize=32768      1  1 

    proc            /proc           proc    defaults        0  0    
    tmpfs           /media/ram      tmpfs   defaults        0  0    
    usbfs           /proc/bus/usb   usbfs   defaults        0  0    
									        
The final step is to initialize the swap space.
LKG123456# mkswap /mnt/swap/swapfile
Setting up swapspace version 1, size = 67104 kB
no label, UUID=dc7a0384-57af-4c08-85e2-6e47c400dbb8
LKG123456# /etc/init.d/swap restart



  This material is based upon work supported by the National Science Foundation under grants #0435454 and #0454432, and the NSF Graduate Research Fellowship Program. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.