Differences between revisions 9 and 10
Revision 9 as of 2006-04-22 22:56:11
Size: 30721
Comment: fixup formatting from the moinmoin upgrade (doesn't like indented headers)
Revision 10 as of 2006-05-02 15:54:19
Size: 30728
Comment: more format fixing
Deletions are marked like this. Additions are marked like this.
Line 80: Line 80:
Line 104: Line 105:
==== Install toolchain ====   ==== Install toolchain ====
Line 148: Line 149:
 Say yes. You may get a warning while configuring binutils about a possible kernel link failure. It applies to older kernels, and we'll be using something newish, so it shouldn't affect us. ==== Building a Kernel ==== Now, download a kernel tarball and unpack. I'll use 2.6.14.2 here.  Say yes. You may get a warning while configuring binutils about a possible kernel link failure. It applies to older kernels, and we'll be using something newish, so it shouldn't affect us.

==== Building a Kernel ====

Now, download a kernel tarball and unpack. I'll use 2.6.14.2 here.
Line 185: Line 190:
==== Building the Madwifi-ng modules and utilities ====  ==== Building the Madwifi-ng modules and utilities ====

Maintaining the Image

The following is a description of how RussellSenior has been working on the software running on the metrixes. When I encountered them, all of the metrixes already had the BenjaminJencks firmware, http://cornerstone.personaltelco.net/~brj/metrix-missnet.img. It is setup with all 3 interfaces bridged, and br0 set to 10.11.104.5/22.referenced above.

Updating in place

The metrix firmware is a minimized Debian distribution. The /etc/apt/sources.list include these archives:

deb http://www.backports.org/debian/ stable kernel-2.6
deb http://debian.oregonstate.edu/debian woody main
deb http://security.debian.org woody/updates main

As long as the metrix has access to the internet it can be updated using the standard Debian methods.

# remountrw
# apt-get update
# apt-get upgrade
# apt-get clean
# remountro

For my personal sanity, I have installed "less". For testing/debugging, I have installed "tcpdump", and to keep the clock remotely in sync I have installed "ntpdate" (this seems to be hanging briefly during bootup, not sure why).

Building Software

In order to incrementally build software (e.g., new kernels, madwifi drivers, utilities) for the metrix, one needs a build environment that corresponds to the one on the metrix. My initial attempt to build the madwifi utilities produced partially-broken results because I failed to do this (binaries were linked against symbols that didn't exist in the metrix-installed libraries). Here are the steps I went through to create and use the build environment.

The host for this work was a Debian/unstable system.

Unpacking the Image

  • First, create a directory in which to work, e.g. /src/mississippi/ and download the starting image there:
    $ mkdir /src/mississippi
    $ cd /src/mississippi
    $ wget http://cornerstone.personaltelco.net/~brj/metrix-missnet.img
    The downloaded file is 64,028,672 bytes (125,056 512-byte sectors). This represents the /dev/hda flash device on the metrix. It includes the boot sector and partition table, and the root partition /dev/hda1. Grub is used as the boot loader (a rather old feature-missing version, which it would be nice to update, to, for example, be able to control the "next boot"). Before we can mount the first partition, we need to dissect the image a bit. We set up a loop block device associated with the image.
    $ losetup /dev/loop0 metrix-missnet.img
    Now, run fdisk on the loop device to figure out where the first partition begins. Use the -u option to fdisk in order to get sector units.
    $ fdisk -u /dev/loop0
     
    Command (m for help): p
    
    Disk /dev/loop0: 64 MB, 64028672 bytes
    4 heads, 32 sectors/track, 977 cylinders, total 125056 sectors
    Units = sectors of 1 * 512 = 512 bytes
    
          Device Boot      Start         End      Blocks   Id  System
    /dev/loop0p1              32      125055       62512   83  Linux
    
    Command (m for help): q
    Take particular note of the starting sector of the first partition. We'll need that in just a bit. Now disassociate /dev/loop0 from the image file.
    $ losetup -d /dev/loop0
    Now you have a choice. You can either make a copy of the first partition, which you can mount, or you can create a new loop block device offset to the start of first partition and modify it "in place". I chose the former in order to preserve the original, but for reference, you can create the offset loop device as follows. Note that 16384 bytes is the starting sector (32) multiplied by the sector size (512 bytes).
    $ losetup -o 16384 /dev/loop0 metrix-missnet.img
    $ mkdir metrix-missnet
    $ su
    # mount /dev/loop0 metrix-missnet
    Now, what I did instead:
    $ dd if=metrix-missnet.img of=metrix-missnet-part1.img skip=32
    125024+0 records in
    125024+0 records out
    64012288 bytes (64 MB) copied, 7.40427 seconds, 8.6 MB/s
    $ mkdir metrix-missnet
    $ su
    # mount -o loop metrix-missnet-part1.img metrix-missnet

Creating the Build Environment

  • Now you have access to the image's filesystem through the metrix-missnet mount point. However, the little 64Meg filesystem is too small for the build tool chain, so we are going to create a working copy next door, that we'll chroot into and install the software there. Because we're working with root owned files, we need to stay root here for a while.
    # rsync -v -a -H metrix-missnet/ metrix-missnet-build-env/
    # chroot metrix-missnet-build-env
    Now a little explanatory digression is necessary. The metrix-native environment runs with the filesystem mounted read-only. It copes with changing files by symlinking them to a /rw tmpfs filesystem. That /rw filesystem gets populated during boot from static versions in a /ro tree. You are going to be needing to install software from Debian archives, but your DNS resolution won't work until you modify the build environment's /etc/resolv.conf to something that works for you locally. However, /etc/resolv.conf is a symlink pointing at /rw/etc/resolv.conf. At this stage, that file doesn't exist, since /rw is just a mount point in the original. There are lots of potential solutions to this problem. I took the most direct one, effectively replicating what the metrix itself does:
    # rsync -v -a -H /ro/ /rw/
    # vi /etc/resolv.conf (as appropriate)
    Then ping some well-known host to confirm that your network is functioning in the chroot.
    # ping www.google.com
    PING www.l.google.com (66.102.7.147): 56 data bytes
    64 bytes from 66.102.7.147: icmp_seq=0 ttl=238 time=56.0 ms
    64 bytes from 66.102.7.147: icmp_seq=1 ttl=238 time=56.4 ms
    64 bytes from 66.102.7.147: icmp_seq=2 ttl=238 time=60.8 ms
    64 bytes from 66.102.7.147: icmp_seq=3 ttl=238 time=59.7 ms
    
    --- www.l.google.com ping statistics ---
    4 packets transmitted, 4 packets received, 0% packet loss
    round-trip min/avg/max = 56.0/58.2/60.8 ms

Install toolchain

For good measure, we'll sync up currently installed packages with the Debian archives, but first we'll modify the /etc/apt/sources.list to accomodate subversion we're going to need soon. Add subversion to the backports line:

  • deb http://www.backports.org/debian/ stable kernel-2.6 subversion
    Then sync up:
    # apt-get update
    Hit http://debian.oregonstate.edu woody/main Packages
    Hit http://debian.oregonstate.edu woody/main Release
    Get:1 http://security.debian.org woody/updates/main Packages [245kB]
    Hit http://www.backports.org stable/kernel-2.6 Packages
    Hit http://www.backports.org stable/kernel-2.6 Release
    Get:2 http://www.backports.org stable/subversion Packages [8729B]
    Get:3 http://security.debian.org woody/updates/main Release [113B]
    Get:4 http://www.backports.org stable/subversion Release [141B]
    Fetched 254kB in 1s (186kB/s)
    Reading Package Lists...
    Building Dependency Tree...
    # apt-get upgrade
    Reading Package Lists...
    Building Dependency Tree...
    7 packages upgraded, 0 newly installed, 0 to remove and 0  not upgraded.
    Need to get 1259kB of archives. After unpacking 61.4kB will be used.
    Do you want to continue? [Y/n] y
    Say yes. Now, install the toolchain and a few tools we'll need:
    # apt-get install make gcc libncurses5-dev subversion sharutils
    Reading Package Lists...
    Building Dependency Tree...
    The following extra packages will be installed:
      binutils cpp cpp-2.95 db4.2-util gcc-2.95 libapr0 libc6-dev libdb4.2
      libexpat1 libldap2 libneon24 libpcre3 libsasl7 libsvn0 libswig1.3.22 libxml2
      patch python python2.1 
    The following NEW packages will be installed:
      binutils cpp cpp-2.95 db4.2-util gcc gcc-2.95 libapr0 libc6-dev libdb4.2
      libexpat1 libldap2 libncurses5-dev libneon24 libpcre3 libsasl7 libsvn0
      libswig1.3.22 libxml2 make patch python python2.1 sharutils subversion 
    0 packages upgraded, 24 newly installed, 0 to remove and 0  not upgraded.
    Need to get 11.7MB of archives. After unpacking 40.4MB will be used.
    Do you want to continue? [Y/n] y
    Say yes. You may get a warning while configuring binutils about a possible kernel link failure. It applies to older kernels, and we'll be using something newish, so it shouldn't affect us.

Building a Kernel

  • Now, download a kernel tarball and unpack. I'll use 2.6.14.2 here.
    # cd /usr/src
    # wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.14.2.tar.bz2
    # tar xjvf linux-2.6.14.2.tar.bz2
    Start with the existing kernel config in /boot:
    # cd linux-2.6.14.2
    # cp /boot/config-2.6.12.3-metrix .config
    # make oldconfig
    I selected defaults for everything, except:
    • Automatically append version information to the version string (LOCALVERSION_AUTO) [Y/n/?] (NEW) n
    • Dell Systems Management Base Driver (DCDBAS) [M/n/y/?] (NEW) n
    • Generic IEEE 802.11 Networking Stack (IEEE80211) [N/m/y/?] (NEW) y
    • Inotify file change notification support (INOTIFY) [Y/n/?] (NEW) n
    Note that this configuration is set up for a Metrix Mark II, with a Soekris 4826 board and a Geode GX1 CPU. In order to work with the Metrix Mark I, which uses a Soekris 4526 and an AMD 486 clone, you need to modify the configuration, e.g. using "make menuconfig". Trying to boot the 4526 with a Geode compiled kernel will choke as follows:
    CPU: AMD 486 DX/4-WB stepping 04
    Kernel panic - not syncing: Kernel compiled for Pentium+, requires TSC feature!
    Next, compile the kernel:
    # make
    # make install 
    # make modules_install 
    The modules are installed in /lib/modules/2.6.14.2-metrix. Edit /boot/grub/menu.lst, adding a stanza for the new kernel. For example:
    title           Debian GNU/Linux, kernel 2.6.14.2-metrix
    root            (hd0,0)
    kernel          /boot/vmlinuz-2.6.14.2-metrix root=/dev/hda1 ro console=ttyS0,19200n8 panic=5
    savedefault
    Since we have no consoles on the metrixes in the field, and no non-volatile storage is available to record any oops messages, there isn't much purpose served by having a panic just halt the device, so I've added the panic clause to the boot options in hopes that will recover the device in the case of a fault.

Building the Madwifi-ng modules and utilities

  • In order to build the madwifi-ng software, we first need to check it out from SVN:
    # cd /usr/src
    # svn checkout http://svn.madwifi.org/trunk madwifi-ng
    # cd /usr/src/madwifi-ng
    Then build the madwifi-ng code. Because you are building it for the newly compiled kernel rather than the one you are running, you need to set some environment variables. As of revision 1329, I also needed to hack the Makefile slightly to get depmod to do the right thing. Maybe not the right fix, but it worked for me. Change the line with depmod to this:
            (export MODULEPATH=${MODULEPATH}; depmod -ae ${KERNELVERSION})
    Now, build madwifi with make:
    # KERNELVERSION=2.6.14.2-metrix KERNELPATH=/usr/src/linux-2.6.14.2 make
    # KERNELVERSION=2.6.14.2-metrix KERNELPATH=/usr/src/linux-2.6.14.2 make install 

Modifying /etc/network/interfaces

  • We also need to revise the /etc/network/interfaces file to support the new madwifi drivers. Some of this configuration (e.g. wlanconfig lines) are new with the madwifi-ng code, so we've added " || true" lines where the earlier madwifi drivers will fail. Eventually we'll just purge the old madwifi stuff and the armor can go at the same time. The br0 address (10.11.104.4) is a dummy value and will need to be modified on any deployed metrix.

    auto lo
    iface lo inet loopback
    iface lo inet6 loopback
     
    auto br0
    iface br0 inet static
            address 10.11.104.4
            netmask 255.255.252.0
            broadcast 10.11.107.255
            gateway 10.11.104.1
            bridge_ports eth0
            bridge_stp on
            bridge_maxwait 0
    
    auto ath0
    iface ath0 inet static
            address 1.0.0.0
            netmask 255.255.255.255
            broadcast 255.255.255.255
            pre-up modprobe ath-pci
            pre-up wlanconfig ath0 create wlandev wifi0 wlanmode sta || true
            pre-up iwpriv ath0 wds 1 || true
            pre-up iwpriv ath0 mode 1
            up brctl addif br0 ath0
            down brctl delif br0 ath0
            post-down wlanconfig ath0 destroy
            wireless_mode managed
            wireless_essid backhaul
    
    auto ath1
    iface ath1 inet static
            address 1.0.0.0
            netmask 255.255.255.255
            broadcast 255.255.255.255
            pre-up modprobe ath-pci
            pre-up wlanconfig ath1 create wlandev wifi1 wlanmode ap || true
            pre-up iwpriv ath1 mode 3
            up brctl addif br0 ath1
            down brctl delif br0 ath1
            post-down wlanconfig ath1 destroy
            wireless_mode master
            wireless_essid www.personaltelco.net
            wireless_channel 1
    In the case of new 802.11a master nodes, we'll need to modify the ath0 stanza to:
    auto ath0
    iface ath0 inet static
            address 1.0.0.0
            netmask 255.255.255.255
            broadcast 255.255.255.255
            pre-up modprobe ath-pci
            pre-up wlanconfig ath0 create wlandev wifi0 wlanmode ap || true
            pre-up iwpriv ath0 wds 1 || true
            pre-up iwpriv ath0 mode 1
            up brctl addif br0 ath0
            down brctl delif br0 ath0
            post-down wlanconfig ath0 destroy
            wireless_mode master
            wireless_essid backhaul
            wireless_channel 165
    We are now finished with the chroot and can exit from it:
    # exit

New WDS configuration
  • The /etc/network/interfaces files are changing to correspond to the WDS model. I have written a short Common Lisp program to automatically generate the interfaces files for each node. Here is the current Lisp code:
    (defvar *backhaul-channel*)
    (defvar *wds-pairs*)
    (defvar *nodes*)
    
    (defclass radio ()
      ((radio :initarg :radio)
       (channel :initarg :channel)
       (macaddr :initarg :macaddr)))
    
    (defclass node ()
      ((name :initarg :name)
       (ipaddr :initarg :ipaddr)
       (radios :initarg :radios)))
    
    (defmacro build-node (name ipaddr channel1 macaddr1 channel2 macaddr2)
      `(make-instance 'node 
                      :name ,name 
                      :ipaddr ,ipaddr
                      :radios (list
                               (make-instance 'radio 
                                              :radio 'wifi0 
                                              :channel ,channel1 
                                              :macaddr ,macaddr1) 
                               (make-instance 'radio 
                                              :radio 'wifi1 
                                              :channel ,channel2 
                                              :macaddr ,macaddr2))))
    
    (defun radio-g (node)
      (let* ((radios (slot-value node 'radios)))
        (find-if (lambda (r) (< (slot-value r 'channel) 12)) radios)))
             
    (defun radio-a (node)
      (let* ((radios (slot-value node 'radios)))
        (find-if-not (lambda (r) (< (slot-value r 'channel) 12)) radios)))
    
    (defun find-peer (name)
      (find-if (lambda (n) (eq name (slot-value n 'name))) *nodes*))
    
    (defun rebuild-interfaces (node prefix)
      (let* ((name (slot-value node 'name))
             (fname (format nil "~a-~a" prefix (string-downcase (symbol-name name))))
             (peers (loop for n in *wds-pairs*
                          if (eq name (car n))
                          collect (cdr n)
                          else if (eq name (cdr n))
                          collect (car n)
                          end))
             (radio-g (radio-g node))
             (radio-g-name (string-downcase (symbol-name (slot-value radio-g 'radio))))
             (radio-a (radio-a node))
             (radio-a-name (string-downcase (symbol-name (slot-value radio-a 'radio)))))
        (with-open-file (out fname
                             :direction :output
                             :if-exists :supersede)
          (format out "auto lo
    iface lo inet loopback
    iface lo inet6 loopback
    
    auto br0
    iface br0 inet static
            address ~a
            netmask 255.255.252.0
            broadcast 10.11.107.255
            gateway 10.11.104.1
            bridge_ports eth0
            bridge_stp on
            bridge_maxwait 0
    
    auto ath0
    iface ath0 inet static
            address 1.0.0.0
            netmask 255.255.255.255
            broadcast 255.255.255.255
            pre-up modprobe ath-pci
            pre-up wlanconfig ath0 create wlandev ~a wlanmode ap
            pre-up iwpriv ath0 mode 3
            up brctl addif br0 ath0
            down brctl delif br0 ath0
            post-down wlanconfig ath0 destroy
            wireless_mode master
            wireless_essid www.personaltelco.net
            wireless_channel ~d
    
    auto ath1
    iface ath1 inet static
            address 1.0.0.0
            netmask 255.255.255.255
            broadcast 255.255.255.255
            pre-up modprobe ath-pci
            pre-up wlanconfig ath1 create wlandev ~a wlanmode ap~%"
                  (slot-value node 'ipaddr)
                  radio-g-name
                  (slot-value radio-g 'channel)
                  radio-a-name)
    
          (loop for p in peers
                for i from 2
                do (format out 
                           "        pre-up wlanconfig ath~d create wlandev ~a wlanmode wds~%"
                           i
                           radio-a-name))
    
          (format out "        pre-up iwconfig ath1 essid backhaul~%")
          
          (loop for p in peers
                for i from 2
                do (format out
                           "        pre-up iwpriv ath~d wds_add ~a~%"
                           i
                           (slot-value (radio-a (find-peer p)) 'macaddr)))
    
          (loop for p in peers
                for i from 2
                do (format out "        pre-up iwpriv ath~d wds 1~%" i))
          (loop for p in peers
                for i from 2
                do (format out "        pre-up ifconfig ath~d up~%" i))
    
          (format out "        up iwconfig ath1 channel ~d
            up brctl addif br0 ath1~%" *backhaul-channel*)
    
          (loop for p in peers
                for i from 2
                do (format out "        up brctl addif br0 ath~d~%" i))
    
          (format out "        down brctl delif br0 ath1~%")
    
          (loop for p in peers
                for i from 2
                do (format out "        down brctl delif br0 ath~d~%" i))
          
          (format out "        post-down wlanconfig ath1 destroy~%")
    
          (loop for p in peers
                for i from 2
                do (format out "        post-down wlanconfig ath~d destroy~%" i))
          
          (format t "[~a] ~a: ~a~%" fname name peers))))
    
    (setq  *backhaul-channel* 165
           *wds-pairs* '((naya-sw . commons)
                         (west . commons)
                         (ed . commons)
                         (ed . naya-nw))
           *nodes*
                      ;                        <========wifi0========> <=======wifi1========>
           (list      ; node-name  ip-addr     cha    mac-addr         cha    mac-addr
            (build-node 'naya-sw "10.11.104.2" 165 "00:02:6F:21:EC:AA"   1 "00:02:6F:21:EC:A5")
            (build-node 'naya-nw "10.11.104.3" 165 "00:02:6F:21:EC:A8"  11 "00:02:6F:21:EC:A6")
            (build-node 'commons "10.11.104.5" 165 "00:02:6F:21:EC:A9"   1 "00:02:6F:21:E9:49")
            (build-node 'west    "10.11.104.8" 165 "00:02:6F:21:EF:ED"   1 "00:02:6F:21:EF:F2")
            (build-node 'ed      "10.11.104.9"   1 "00:02:6F:21:EF:F0" 165 "00:02:6F:21:EF:F1")))
    
    (loop for n in *nodes*
          do (rebuild-interfaces n "/tmp/interfaces"))
    The configuration all takes place in the last SETQ clause. The final LOOP builds a new /etc/network/interfaces-FOO file in /tmp/interfaces-FOO, for each node named FOO. The *WDS-PAIRS* variable indicates which nodes talk to which others. The BUILD-NODE clauses define the node names, ip number, which mac addresses and antennas are attached with which pci slots (the 165 here is not used except to indicate an 11a radio, it gets overridden by the *BACKHAUL-CHANNEL* variable when writing the interfaces file). Note that metrix-ed's 11a and 11b/g antennas are wired backwards from everywhere else. To run this code to generate the interface files on a Debian system, apt-get install clisp, save the code block above to reconfig.lisp, then run the program as follows:
    $ clisp reconfig.lisp

Installing the new software

  • The steps above have installed new software in /boot, /lib/modules, and /usr/local as well as the /etc/network/interfaces file we just changed in the last step. We can use rsync to put these changes into place, but we don't want to do an rsync from the root directory as our build environment has excessive cruft. Instead, we want to explicitly rsync the trees/files indicated above. If the target of the modification is a running metrix, then you should probably rsync from there over the network, like so:
    $ slogin buick.personaltelco.net
    $ slogin root@metrix-foo
    # remountrw
    # rsync -v -a -H username@hostname:/src/mississippi/metrix-missnet-build-env/boot/ /boot/
    # rsync -v -a -H username@hostname:/src/mississippi/metrix-missnet-build-env/lib/modules/ /lib/modules/
    # rsync -v -a -H username@hostname:/src/mississippi/metrix-missnet-build-env/usr/local/ /usr/local/
    # scp username@hostname:/src/mississippi/metrix-missnet-build-env/etc/network/interfaces /etc/network/interfaces
    # remountro
    You'll need to be a little careful with /etc/network/interfaces, in particular setting the br0 address correctly and making sure you've got ath0 master/managed mode configured correctly. To install in the locally-mounted (at /src/mississippi/metrix-missnet) partition image, do similarly:
    # rsync -v -a -H /src/mississippi/metrix-missnet-build-env/boot/ /src/mississippi/metrix-missnet/boot/
    # rsync -v -a -H /src/mississippi/metrix-missnet-build-env/lib/modules/ /src/mississippi/metrix-missnet/lib/modules/
    # rsync -v -a -H /src/mississippi/metrix-missnet-build-env/usr/local/ /src/mississippi/metrix-missnet/usr/local/
    # cp /src/mississippi/metrix-missnet-build-env/etc/network/interfaces /src/mississippi/metrix-missnet/etc/network/interfaces
    We are now finished with the loopback mounted partition, so we can unmount it.
    # cd /src/mississippi
    # umount metrix-missnet

Creating a new image

  • To create a new image, we can crib the first 32 sectors from the original image, then paste on our modified filesystem part. We can do this as non-root. Note, we got the 32 from our fdisk examination of the original image. Substitute a different value as necessary.
    $ dd if=/src/mississippi/metrix-missnet.img of=/src/mississippi/metrix-missnet-new.img count=32
    32+0 records in
    32+0 records out
    16384 bytes (16 kB) copied, 0.044728 seconds, 366 kB/s
    $ dd if=/src/mississippi/metrix-missnet-part1.img of=/src/mississippi/metrix-missnet-new.img seek=32
    125024+0 records in
    125024+0 records out
    64012288 bytes (64 MB) copied, 6.51654 seconds, 9.8 MB/s
    Viola! There's our new image, metrix-missnet-new.img, ready to install.

Installing an image

  • In the case that there is a running system on the device, the solution is easy. Log in to the device, leave /dev/hda1 mounted read-only, and execute something like this, where "hostname" is the build machine and "username" is an account that has read access to that image:
    # ssh username@hostname 'dd if=/src/mississippi/metrix-missnet-new.img' | dd of=/dev/hda1
    Writing underneath a mounted filesystem is a little rude, but since it is read-only, the only bad result might be that the running system gets confused. Reboot immediately after the dd completes and you should be fine. If the running system doesn't have ssh, you can use wget instead. Something like:
    # wget -O - <url-of-metrix-missnet-new.img> | dd of=/dev/hda1

Flashing overview

  • If the device does not have a running system, then we'll need to bootstrap. Since the flash on the Soekris boards is soldered on, you can't simply remove it to program on a different machine. Basically, you need to netboot enough of a system to dd the image onto the flash. The approach I took is to netboot the Soekris with an nfs-mounted root filesystem, and then dd directly from that nfs mount. We will need three services (dhcp, tftp, and nfs) and a serial console to perform this operation. We will need a kernel and a root filesystem. It goes something like this. With a serial console installed, we boot the metrix with ethernet connectivity to the services. We need the serial console in order to force a PXE boot. PXE requests information from the DHCP server, which hands it network configuration information as well as points it at the TFTP server and the bootloader. The TFTP server provides the pxelinux.0 bootloader and a LILO-like configuration file with the kernel boot parameters. The metrix loads the kernel via TFTP and mounts a root filesystem via NFS. Once thus booted, we can login and dd our image to /dev/hda.

Preparing a kernel for netbooting

  • We need a kernel to netboot from that has NFS support, and furthermore we need a root filesystem with a user space sufficient to support the flashing. Luckily, we just built very nearly those things in the steps above. We just need to tweak them slightly and they'll be good to go. We'll need to chroot back into our build environment and make the kernel reconfiguration changes:
    # chroot /src/mississippi/metrix-missnet-build-env
    # cd /usr/src/linux-2.6.14.2
    # make menuconfig
    • Turn on NFS support and kernel level autoconfiguration:
      Networking ---> Networking options ---> IP: kernel level autoconfiguration
      Networking ---> Networking options ---> IP: DHCP support
      File systems ---> Network File Systems ---> NFS file system support [Y]
      File systems ---> Network File Systems ---> Provide NFSv3 client support [Y]
      File systems ---> Network File Systems ---> Root file system on NFS [Y]
      Save the configuration and recompile the kernel and madwifi drivers for good measure, just to keep things in sync.
      # make
      # make install
      # make modules_install
      # cd /usr/src/madwifi-ng
      # KERNELVERSION=2.6.14.2-metrix KERNELPATH=/usr/src/linux-2.6.14.2 make clean
      # KERNELVERSION=2.6.14.2-metrix KERNELPATH=/usr/src/linux-2.6.14.2 make install
      # exit
      Upon leaving the chroot, push the changes into our partition image, mounting it if necessary.
      # mount -o loop /src/mississippi/metrix-missnet-part1.img /src/mississippi/metrix-missnet
      # rsync -v -a -H /src/mississippi/metrix-missnet-build-env/boot/ /src/mississippi/metrix-missnet/boot/
      # rsync -v -a -H /src/mississippi/metrix-missnet-build-env/lib/modules/ /src/mississippi/metrix-missnet/lib/modules/
      # rsync -v -a -H /src/mississippi/metrix-missnet-build-env/usr/local/ /src/mississippi/metrix-missnet/usr/local/
      # cp /src/mississippi/metrix-missnet-build-env/etc/network/interfaces /src/mississippi/metrix-missnet/etc/network/interfaces

Setting up services

  • DHCP: (using the dhcp3-server package) I added the following lines to my Debian /etc/dhcp3/dhcpd.conf file:
    allow booting;
    allow bootp;
    
    group {
            next-server <tftp-server-ip>;
            filename "pxelinux.0";
            option root-path "<nfs-server-ip>:/aux/metrix/rootfs";
    
            host metrix {
                    hardware ethernet <metrix-eth0-macaddr>;
                    fixed-address <metrix-ip>;
          }
    }
    Then restart the service:
    # /etc/init.d/dhcp3-server restart
  • TFTP: (using the tftpd-hpa package)
    # cd /var/lib/tftpboot
    # wget http://centerclick.org/net4801/pxelinux/pxelinux.0.gz
    # gunzip pxelinux.0.gz
    # mkdir pxelinux.cfg
    # cat > pxelinux.cfg/default <<EOF
    SERIAL 0 19200
    
    PROMPT 1
    TIMEOUT 40
    
    # nfs root
    DEFAULT metrix/vmlinuz console=ttyS0,19200n81 root=/dev/nfs rw ip=dhcp
    EOF
    # mkdir metrix
    # scp username@hostname:/src/mississippi/metrix-missnet-build-env/boot/vmlinuz metrix/vmlinuz
  • NFS: (using the nfs-kernel-server package) Add an export for the metrix's rootfs:
    /aux/metrix/rootfs      <metrix-ip>(rw,no_root_squash)
    Then restart the service:
    # /etc/init.d/nfs-kernel-server restart
    From the NFS server, copy the rootfs from the mounted (at /src/mississippi/metrix-missnet) metrix-missnet-part1.img, as well as the new image we want to flash.
    # rsync -v -a -H hostname:/src/mississippi/metrix-missnet/ /aux/metrix/rootfs/
    # scp hostname:/src/mississippi/metrix-missnet-new.img /aux/metrix/rootfs/usr/src/
    The network configuration for flashing from an nfs-mounted rootfs is going to be different than what we want deployed. In the flashing configuration, auto configuring the eth0 interface with the field configuration is going to mess up the the nfs mount. So, comment out the existing auto's (br0, ath0, ath1) and insert this stanza in the NFS server's /aux/metrix/rootfs/etc/network/interfaces:
    auto eth0
    iface eth0 inet dhcp

Netbooting

  • Attach a null-modem cable to the Soekris serial port;
  • Configure minicom (or similar) to 19200 baud, N81, no flow control;
  • Apply power to the device, and watch messages:
    comBIOS ver. 1.24  20040312  Copyright (C) 2000-2004 Soekris Engineering.
    
    net45xx
    
    0064 Mbyte Memory                        CPU 80486 133 Mhz 
    
    Pri Mas  064MB ATA Flash Disk            LBA 977-4-32  62 Mbyte
    
    PXE-M00: BootManage UNDI, PXE-2.0 (build 082)
    
    Slot   Vend Dev  ClassRev Cmd  Stat CL LT HT  Base1    Base2   Int 
    -------------------------------------------------------------------
    0:00:0 1022 3000 06000000 0006 2280 00 00 00 00000000 00000000 00
    0:16:0 168C 0013 02000001 0116 0290 10 3C 00 A0000000 00000000 10
    0:17:0 168C 0013 02000001 0116 0290 10 3C 00 A0010000 00000000 11
    0:18:0 100B 0020 02000000 0107 0290 00 3F 00 0000E001 A0020000 05
    
     5 Seconds to automatic boot.   Press Ctrl-P for entering Monitor.
  • When you see the Ctrl-P, press Ctrl-P to enter the comBIOS Monitor;
  • Boot PXE
    > boot f0
  • The metrix should boot, mount its rootfs over NFS and supply a login prompt on the serial console;
  • Login as root and flash the image:
    # dd if=/usr/src/metrix-missnet-new.img of=/dev/hda bs=64k
    977+0 records in
    977+0 records out
    # reboot
  • Let it boot normally this time and you become the proud owner of a reflashed metrix. Happy Hacking!


[CategoryDocumentation]

MississippiMetrixConfiguration (last edited 2009-01-31 02:10:15 by RussellSenior)