Firmware Image
The image for the Metrix boxen is at 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.
To flash:
- Setup a sarge installer pxeboot environment.
Instructions at http://www.debian.org/releases/stable/i386/ch04s06.html.en
The pxelinux included with debian tries to use both the VGA emulation and the serial console. This causes problems. Use pxelinux.0 from http://centerclick.org/net4801/pxelinux/ instead.
- Use the serial console pxeboot config.
- Change all the 9600 to 19200 in the config.
- You probably want to add DEBIAN_FRONTEND=text to the boot options of the kernel you'll use. Use expert26.
- Netboot the metrix into the installer
- Attach a serial terminal.
- 19200 baud, 1 bit parity, no flow control
- Press ctrl+p at the prompt to get to the BIOS
boot f0
- Use expert26. You don't need any extra options.
- Go through the installer up through step 9 (Download installer components). This is where device drivers are loaded.
- After the drivers are loaded, go to a shell.
wget -O - http://somewhere/foo/metrix-missnet.img | dd of=/dev/discs/disc0/disc bs=1M (don't get it straight from cornerstone, copy it to your machine first)
- Reboot
Note: as of 2005-10-11 this process isn't working for me. The Metrix stalls during the PXELINUX stuff. I think it's probably just an issue with my setup but I've got it working fine using the documentation from Metrix. (- KeeganQuinn)
The way the Metrix website says to do it is actually better. When I was working on the metrixes, though, that documentation didn't exist, to my memory. The debian netboot was simply the easiest way I could find to get a shell netbooted. (- BenjaminJencks)
Can KeeganQuinn or BenjaminJencks please point at or reiterate the referred-to Metrix documentation here? --RussellSenior
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, 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 $ 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 ====# 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] Get:2 http://security.debian.org woody/updates/main Release [113B] Hit http://www.backports.org stable/kernel-2.6 Packages Hit http://www.backports.org stable/kernel-2.6 Release Fetched 245kB in 5s (48.4kB/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]
Say yes. Now, install the toolchain:# apt-get install make gcc libncurses5-dev Reading Package Lists... Building Dependency Tree... The following extra packages will be installed: binutils cpp cpp-2.95 gcc-2.95 libc6-dev The following NEW packages will be installed: binutils cpp cpp-2.95 gcc gcc-2.95 libc6-dev libncurses5-dev make 0 packages upgraded, 8 newly installed, 0 to remove and 0 not upgraded. Need to get 6576kB of archives. After unpacking 24.8MB will be used. Do you want to continue? [Y/n]
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. I'll use 2.6.14.2 here. Since I forgot to install bzip2 above, I'll just download the gzip'd tarball and unpack it:# cd /usr/src # wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.14.2.tar.gz # tar xzvf linux-2.6.14.2.tar.gz
Start with the 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:- 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
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. For that we need to install the subversion Debian package. But subversion isn't in the ordinary archives, so we can add it to the backports line of /etc/apt/sources.list:deb http://www.backports.org/debian/ stable kernel-2.6 subversion
Then:# apt-get update Hit http://debian.oregonstate.edu woody/main Packages Hit http://debian.oregonstate.edu woody/main Release Hit http://security.debian.org woody/updates/main Packages Hit http://security.debian.org woody/updates/main Release Hit http://www.backports.org stable/kernel-2.6 Packages Hit http://www.backports.org stable/kernel-2.6 Release Get:1 http://www.backports.org stable/subversion Packages [8729B] Get:2 http://www.backports.org stable/subversion Release [141B] Fetched 8870B in 1s (6053B/s) Reading Package Lists... Building Dependency Tree... # apt-get install subversion Reading Package Lists... Building Dependency Tree... The following extra packages will be installed: db4.2-util libapr0 libdb4.2 libexpat1 libldap2 libneon24 libpcre3 libsasl7 libsvn0 libswig1.3.22 libxml2 patch python python2.1 The following NEW packages will be installed: db4.2-util libapr0 libdb4.2 libexpat1 libldap2 libneon24 libpcre3 libsasl7 libsvn0 libswig1.3.22 libxml2 patch python python2.1 subversion 0 packages upgraded, 15 newly installed, 0 to remove and 0 not upgraded. Need to get 5057kB of archives. After unpacking 15.3MB will be used. Do you want to continue? [Y/n]
Say yes. Now check out the madwifi-ng code with:# 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})
[oops need to install package "sharutils" for uudecode too ... ought to move all of the apt-get installs to the beginning] 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
==== Installing the new software ==== We are now finished with the chroot and can exit from it:# exit
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 ==== [ more to come ]