ROCK on Soekris

From RockWiki

Jump to: navigation, search

I wrote this article some years ago. So the ROCK Router Images I've used for the install are totally outdated nowdays. But the concepts for doing PXE Installs didn't change since then.

Contents

Introduction

Wim Vandeputte lent me a Soekris net4521 so I could try installing/porting ROCK Router Linux on it. My original intent was to make some clean adaptions to the router target so it could also be built for having system and configuration on a flash disk (rather than loading the system from a cd-rom into memory and storing the configuration on a floppy disk, which is the default right now). But I only had enought time to make some proof-of-concept adaptions to a pre-built router. I'm writing about this now and hope to be able to present a new revision of the ROCK Router later this year, when there are not so many other things to do and more time for doing actual coding work.

As you can see on the picture, the device is pretty small. It's only a bit larger than a dvd, aproximately the same size as my subnotebook. Technical details about the device can be found at https://www.soekris.com and https://soekris.kd85.com.

Adapting the router system

The ROCK Router Linux is a CD-ROM containing a kernel image, a root filesystem image and isolinux as boot loader. I simply loop-mounted the root filesystem image and copied the directory tree to a local directoy on my laptop, added some missing programs (e.g. the grub bootloader) as well as the kernel image from the router CD-ROM and created a tar.gz of it. That's all. The tar.gz can be downloaded here.

PXE-Booting the device

I connected the serial console port of the router to my laptop using a null modem cable and a usb-to-serial cable and connected the eth0 port of the router to my laptops eth0 port using a cross-over cable (see picture). Before pxe-booting the router I needed to set up a dhcp server and a tftp server on my laptop.

Setting up DHCP was easy by just creating a /etc/dhcp.conf file and running "dhcpd":

ddns-update-style ad-hoc;

default-lease-time 600;
max-lease-time 7200;

authoritative;

subnet 10.5.5.0 netmask 255.255.255.0 {
    range 10.5.5.100 10.5.5.199;
    filename "pxelinux.0";
}

The laptop was configured to run on ip 10.5.5.1 in this setup.

Setting up tftpd was even easier. Just creating a /tftpboot directory and running "in.tftpd -l -s /tftpboot" was enough. But it's important to use tftp-hpa or any other tftp package which also implements the "tsize" TFTP option which is defined in RFC 1784/RFC 2349. The pxelinux bootloader won't work with older tftp versions which do not implement this feature.

Next, pxelinux needed to be installed. It is part of the syslinux package which can be downloaded from https://syslinux.zytor.com. The file pxelinux.o, from syslinux, as well as vmlinuz and initrd.img, from the ROCK install CD, needed to go in /tftpboot, along with the configuration file for the boot loader (/tftpboot/pxelinux.cfg/default):

DEFAULT ramdisk

SERIAL 0 19200 0

LABEL ramdisk
    kernel vmlinuz
    APPEND initrd=initrd.img root=/dev/ram devfs=nocompat init=/linuxrc rw console=ttyS0,19200

Note that the Soekris hardware is using a terminal speed of 19200 bps on it's serial console. This is rather unusual - most devices run at 9600 bps. I configured pxelinux and the linux kernel to use the same terminal speed so it's not needed to switch the speed when the bios has finished and the boot loader is running.

Ok - let's ROCK. Power on the device and press Ctrl-P to enter the bios prompt. The command "boot f0" starts the pxe bios and boots pxelinux from the laptop. Pxelinux loads the kernel, and the kernel loads the 1st stage install disk into memory, all on the serial console. What follows next is in no way different from a normal network installation: Loading the network device driver (natsemi), configuring the ip address (10.5.5.20/24), and loading the 2nd stage system from an http server. When prompted for terminal devices, 'tts/0' was entered. The 2nd stage install system re-configures all terminals to 38400 bps by default. So the terminal needed to be reconfigured to the new speed. A complete log of the bootup can be found here.

Installing the system

Using cfdisk, a linux partition was created and marked as bootable. My terminal program doesn't understand the "linux" terminal escape codes - so I set $TERM to "vt220" first. After that the filesystem was created and mounted on /mnt/target as usual. Then the router filesystem tar.gz was put into the htdocs directory of the laptop, and from there installed onto the router:

wget -O - https://10.5.5.1/routerfs.tar.gz | tar -C /mnt/target -xzf -

Switching to the new system using chroot(), and installing grub is also easy, but can't be done using grub-install because that's a shell-script and tools like 'sed' are missing:

# cd /mnt/target
# chroot . bin/bash --login
# mount -n /proc
# mount -n /dev
# grub
grub> root (hd0,0)
grub> setup (hd0)
grub> quit
# umount /dev /proc
# exit

That's it. The routerfs.tar.gz already contains a grub menu.lst file for this setup:

timeout 8
default 0
fallback 1

serial --unit=0 --speed=19200
terminal serial

title ROCK Router Linux
kernel (hd0,0)/boot/vmlinuz root=/dev/ide/host0/bus0/target0/lun0/part1 ro console=ttyS0,19200

After unmounting /mnt/target and rebooting the box, the router was configured by adding the networking and firewalling configuration to /sbin/init. After another reboot the machine was ready for in-production use in my home LAN - at least for the few remaining days until I need to give it back to Wim.

Personal tools