Wednesday February 22, 2012 19:55:39 UTC
How to install Slackware 12.2 on a Soekris Net5501

Introduction


This how-to will cover how to setup the Slackware 12.2 distribution on a Soekris Net5501 using a Compact Flash card. I chose to go in what my opinion is the simplest route for the installation procedure. This involves using a compact-flash to IDE adapter and installing the distribution via another PC. The nice thing about installing using this method is that once the installation is complete, you can simply move the CF card to the Soekris CF slot and Slackware will be able to boot. Also, installation is quick and simple.

Install environment

For my install system, I pulled a motherboard tray out of an old case and used some spare parts collecting dust in the garage. In my case, I had an EVGA 780i / Q6600 that I used along with some memory, PSU, DVD drive, and my CF adapter for this system. Here is an image of my setup:

PC install system image

This configuration makes it simple to swap the CF card back and forth as necessary. I also use this system to make images of my CF card for deployment to other Soekris devices. Feel free to use any hardware of your choosing. I would recommend having the CF adapter setup as the Master on the first IDE slot so the kernel detects the drive as /dev/hda, which is what the Soekris will see the drive partition as also.

The CF adapter I bought is the SYBA SD-CF-IDE-A IDE to Compact Flash Adapter. It only costs $11 on Newegg.com and it works great.

Slackware Installation

I will outline a step-by-step procedure on how I installed Slackware on my CF card for the Soekris.

The first thing to do is to grab the Slackware image. In my case, I only need the first CD ISO since it has the packages I need including the development tools. For the Soekris, I chose to install the following packages trees: a / ap / l / n. Feel free to choose the packages that match your application requirements.

Once your install system is setup, boot the system using the Slackware installation disc. Make sure the CD/DVD drive is set as the first boot device in BIOS. Once the Slackware boot loader loads, hit Enter. You will get a couple notices after the kernel and file system has loaded. Just hit Enter twice to get to a prompt. The first thing to do is to create a partition on your CF card. If you plan to make an image of your CF card later for deployment, I would recommend using one that is small enough to meet your requirements so that the image does not end up being excessively large. In my case, I decided to use a 512MB flash card and used all available space for the partition. I used fdisk to create a partition using all available storage on the CF card. Assuming the CF card is blank, here is how to setup the partition:

fdisk /dev/hda

n
p
1
-Enter-
-Enter-
a
1
w
q
This will setup one primary partition marked bootable using all available space. I choose not to setup a swap partition because there is more than enough memory on the Soekris to handle what I needed and to save the life of the CF card. Feel free to customize the partition table.

These are the steps for the installation itself:
setup

-> Select "Target: Select your target partitions"

-Enter- to select /dev/hda1

-> Select "Format: Quick format with no bad block checking"

Select a file system. I normally choose XFS.

When formatting is complete, you will see your fstab entry and then you can hit -Enter- again.

-> Select "1: Install from a Slackware CD or DVD"

-> Select "auto: Scan for the CD or DVD drive"

You will now be at the package series selection window. Select the package series that you want and hit -Enter-. 
At a minimum you need the "a" series.

-> Select "menu: Choose individual packages from interactive menus"

You will be prompted to select packages for each package series. Go through the menus and select the ones you want.

When the package installation has completed, you will be asked if you want to create a USB Linux boot stick.

-> Select: "Skip: Skip making a USB boot stick"

The next step is the LILO boot loader.

-> Select: "expert: Use expert lilo.conf setup menu"

-> Select: "Begin: Start LILO configuration with a new LILO header"

You will be asked to enter optional parameters. Leave this blank for now, as I will cover how to set this up
in my serial port section later on.

-> Select: "No for Use UTF-8 Text Console"

-> Select "standard: Use the standard Linux console"

-> Select "MBR: Use the Master Boot Record"

Select the default /dev/hda and hit -Enter-

-> Select "5: 5 seconds"

-> Select "No for Optional Slackware Logo Boot Screen"

You will now be returned to the Expert Lilo Installation menu.

-> Select "Linux: Add a Linux partition to the LILO config"

-> Enter "/dev/hda1 for Select Linux Partition"

-> Enter "Linux or another name of your choosing for Select Partition Name"

You will now be returned to the Expert Lilo Installation menu.

-> Select "Install: Install LILO"

You will now be at the Mouse Configuration menu.

-> Select "ps2: PS/2 port mouse"

-> Select "No for GPM Configuration"

You can now select which services you want to have start on boot. I prefer to only select rc.ssh. Later in
this document, I will describe how to set syslog to write to a Ramdisk instead of to the CF card in order to
save the life of the card. I usually start rc.syslog manually when I need it.

-> Select "No for the Console Font Configuration Menu"

You can now select whether you want the hardware clock set to UTC.

If you select No for UTC, you can select the Timezone of your choosing in the next menu.

In the next menus, you will be able to set your network configuration. Choose either DHCP or static IP address.
If you choose static IP address, you will be asked for a host name, domain name, IP address, netmask, gateway, and
DNS server. At the end of the configuration, you will have a menu to confirm your settings.

The last menu is for setting a Root password. Choose Yes here and enter your root password. You will have to enter
the password twice.

You have now completed the Slackware Setup. Select Ok and Select Exit to exit the setup menu.

Your CF card should now be ready to boot on the Soekris. It will also boot on your build PC.
Before rebooting the system, you can also setup init to have agetty open a serial port of your choosing and to provide a login. To do this, follow these steps:
mount /dev/hda1 /mnt
cd /mnt/etc
vi inittab
Uncomment the following line and set it as follows:

# Local serial lines:
s1:12345:respawn:/sbin/agetty -L -i ttyS1 19200 vt100
ttyS0 is for the external 9-pin port and ttyS1 for the internal 10-pin port. Set above to your choosing. I have more information in my serial port section below. Now we have to adjust /etc/securetty to allow login via these tty devices.
cd /mnt/etc
vi securetty
Uncomment or add ttyS0 and ttyS1.
umount /dev/hda1
After you have booted up your Soekris with the new installation, please review my serial port section below to determine how to setup the serial in /etc/lilo.conf.

Soekris Serial Ports

The Soekris has two serial ports. The first serial port is an external 9-pin and is labeled Console. The second one is an onboard 10-pin header. You can tie the console into either port. The default settings for the serial port are:
BAUD rate: 19200
Data bits: 8
Parity: None
Stop bits: 1
Flow control: None
You will need a null-modem adapter to communicate with the Soekris via a terminal program like Minicom or HyperTerminal.

These are the devices for the serial ports as detected by the kernel:

/dev/ttyS0 - External 9-pin connector
/dev/ttyS1 - Internal 10-pin connector

For the 10-pin header, you can use a 10 to 9-pin serial adapter that commonly comes with motherboards. In my install system image above, you can see what one of these cables looks like on the right side of my motherboard. This same kind of cable will work for the Soekris motherboard also. You just have to make sure that the adapter has 10 open holes. Some come with a single closed off hole and that will not fit unless you cut or bend a pin out of the way on the board.

There are two areas that you will want to setup the serial port at. One is in lilo.conf for your kernel image section. This will make it so that the kernel messages will display to the console. The second place is in /etc/inittab. The entry added to this file will be used for allowing you to login via the console and to access your system.

To setup lilo, execute:
vi lilo.conf
Example lilo.conf image section:

image = /boot/linux-2.6.29.2
  root = /dev/hda1
  label = Soekris
  read-only
  append="console=ttyS1,19200n8"
In the append section, you can set either the ttyS0 or ttyS1 device depending on the serial port you want to use. After editing this file, execute the following:
lilo
To setup inittab, you can uncomment the following line there is already present:
vi /etc/inittab
# Local serial lines:
s1:12345:respawn:/sbin/agetty -L -i ttyS1 19200 vt100
As with lilo.conf, you can set either the ttyS0 or ttyS1 device depending on the serial port you want to use. Now we need to reload init:
telinit Q
The Soekris also has the option to set a different Baud rate. In order to do that, you have to enter the Soekris BIOS on bootup. You will see a message on boot to hit CTRL+P to enter BIOS. Do this once the message appears. Execute:
set ConSpeed=(Enter the serial speed of your choosing here)
reboot
If you do this, you will also want to update the 19200 entries in /etc/lilo.conf and /etc/inittab to match what you entered in BIOS.

Building a current optimized kernel for the Soekris

In order to build an up-to-date kernel, I setup a virtual machine with Slackware 12.2 using a similar configuration as my Soekris installation except with the necessary development tools. You can use the virtualization software of your choosing such as VMWare, Virtual PC, or QEMU. I prefer to use this environment on my primary PC for several reasons. Those reasons include my main PC having a much faster processor for quick compilation, to minimize excessive writes to the CF card, and also because there might only be limited space on the CF card.

I chose to use the latest available kernel from ftp.kernel.org. In my case, I ended up using 2.6.29.2. To make life easy, I will provide a kernel configuration that has everything you need to get going. This configuration will be optimized for the Geode GX/LX processor. It also includes support for the IDE chipset, onboard SATA port, network ports, serial ports, EXT2/3 and XFS file system, USB support, and full networking support. There are some other things also. If you decided to select another file system other than XFS during the installation, you will want to select the file system as being built into the kernel instead of as a module. That way the kernel can mount the root file system on boot. I only have XFS as being built into the kernel with my kernel configuration.

Linux 2.6.29.2 kernel configuration download

This configuration should work with any of the 2.6.29 kernels and likely future newer or slightly older kernel versions.

I usually untar my linux source code in /usr/src; however, feel free to put it wherever you like. Here are the steps for building the kernel:
cd /usr/src (or other directory of your choosing)
tar xjf linux-2.6.29.2
cd linux-2.6.29.2
wget the config file from my link above and rename the file to .config
mv config-2.6.29.2 .config

make menuconfig
Here is where you can select the kernel options of your choosing. I have provided you with a base config for the Soekris to start with. It should work without any modification except for possibly the file system depending on which one you choose. You will need a few development tools to build the kernel. These are the ones I installed.
autoconf
automake
binutils
gcc (base package with c compiler)
glibc (from l series so that the necessary libc header files are installed)
ncurses
To build the kernel and modules:
make bzImage
make modules
For multiple processors, you can add -j(number of processors) to the make commands above for a faster build. For example: make bzImage -j4 for a 4-processor build. Your kernel build should be complete now.

For the installation, I will provide a simple script that will put everything kernel related in a temporary directory and make a tgz file that can be transferred to the Soekris for installation. You will want to run it from the kernel source main directory where you ran make bzImage.

Linux kernel install script

In the script, update the KERNEL_VER to the version you are using. The default INSTALL_DIR is /tmp/root where the kernel files will go. You can update this also.

You will now have a file in /tmp/root or the install directory of your choosing called soekris.tgz. Transfer this file over to your Soekris and execute the following commands as root on the Soekris:
cd /
tar xzf ~/soekris.tgz (or the location where you put soekris.tgz)
cd /boot
rm System.map
ln -s System.map-2.6.29.2 System.map (set the 2.6.29.2 to your kernel version)
cp /etc/lilo.conf /etc/lilo.conf.orig
vi /etc/lilo.conf
Now we will setup the lilo.conf. Here is the lilo.conf that I use that also includes the Slackware default kernel:
boot = /dev/hda
append=" vt.default_utf8=0"
prompt
timeout = 100
vga = normal
install = text
lba32

image = /boot/linux-2.6.29.2
  root = /dev/hda1
  label = Soekris
  read-only
  append="console=ttyS1,19200n8"

image = /boot/vmlinuz
  root = /dev/hda1
  label = Linux
  read-only
The first image is the image for your new Soekris kernel and it will boot by default. Update the 2.6.29.2 part of the image location to the correct kernel version that you are using. You can also update the tty device and baud rate in the append section of the first image as describe in my serial port section. The "install = text" option is so that the boot menu will be text based for ease of viewing in a terminal program. The second image is our default Slackware kernel. This image is handy if you decide to put the CF card back in your build PC. We now have to reload the lilo:
lilo
You can now reboot and try out the new kernel. The new kernel should load by default.

How to deal with the long boot delay when the serial console cable is disconnected

If you decide to boot the Soekris with the serial cable disconnected from the console port, you will find a very long delay for the boot loader / kernel to load. To fix this, you have to enter the Soekris BIOS on bootup. You will see a message on boot to hit CTRL+P to enter BIOS. Do this once the message appears. Execute:
set ConMute=Enabled
reboot
After making this change, your system will boot without delay when the console cable is disconnected. The downside is that you will not see the BIOS messages on bootup. However, you can still hit CTRL+P to get into BIOS if you time it right. You will still be able to see the kernel messages and login via the console.

Setting up a Ramdisk for logs and bash_history files

With the embedded projects I have worked on that run off some kind of flash storage, I prefer to store any files that might change on a regular basis in RAM instead of on the flash device. I use the kernel brd module and the Minix file system for this purpose. I prefer to use Minix over EXT2 because Minix has less file system overhead and is good for up to 64MB in size. Normally what I do is move anything relevant in /var/log including the files created via /etc/syslog.conf and any other files that changes on a regular basis into /var/tmp, which is where my ramdisk is mounted. I also move the user directory .bash_history files into /var/tmp and link these files back to the user home directories.

Here is a command layout of how I set this up in /etc/rc.d/rc.local on bootup.
# Setup the RAM disk and file system
modprobe brd
modprobe minix
/usr/bin/dd if=/dev/zero of=/dev/ram0 bs=1k count=16384
/sbin/mkfs.minix /dev/ram0 16384
mount /dev/ram0 /var/tmp

# Make directories in RAM for user bash history files
mkdir -p /var/tmp/users/root
mkdir /var/tmp/users/testuser
touch /var/tmp/users/testuser/.bash_history
touch /var/tmp/users/root/.bash_history
chown -R testuser:users /var/tmp/users/testuser

# Makes some of the common files found in /var/log that we will have link back to here
mkdir /var/tmp/log
for f in btmp cron dmesg faillog lastlog wtmp; do
    touch $f;
done

# Save the contents of 'dmesg':
/bin/dmesg -s 65536 > /var/log/dmesg
Edit /etc/rc.d/rc.M and comment out the line that pipes dmesg to /var/log/dmesg.

If you use my kernel config provided in this document or the default Slackware kernel, the brd and minix modules should be available.

For each user, I create a symbolic link to the files in /var/tmp/users. I do this once, not on bootup. For example:
cd /home/testuser
rm .bash_history
ln -s /var/tmp/users/testuser/.bash_history .
Here is how to create the symbolic links in /var/tmp/log to /var/log.
cd /var/log
for f in btmp cron dmesg faillog lastlog wtmp messages syslog debug secure cron maillog spooler; do
    ln -s /var/tmp/log/$f .;
done
I keep a copy of rc.syslog in /root that has executable permission so that I can start syslog when I need it rather than having it start on boot.

You can do the same or something similar for any other files that might be better off in RAM rather than on flash.

Making an image of the CF card for deployment

In my case, I needed an image of my final Linux environment that could easily be deployed to many other Soekris devices using the same CF cards. I used dd to make an image of my CF card for this purpose. In order to do this, I moved my Soekris CF card back into the CF adapter in my install system. I booted up using my Slackware installation CD and loaded up the system.

The first thing to do before making an image is to modify the udev file that has the listing of Ethernet ports found including MAC address and interface name for each port found on your first Soekris. The reason why you want to do this is because if you leave the existing entries in there, when you boot the image off a new Soekris, udev will setup the new Ethernet ports it finds in addition to the ones already setup. Those will end up being setup as eth4 - eth7 instead of eth0 - eth3 which is what we want. Execute the following commands:
mount /dev/hda1 /mnt
vi /mnt/etc/udev/rules.d/70-persistent-net.rules
Delete the four Ethernet devices starting with "SUBSYSTEM" in this file. You can leave the comments at the top of the file alone. Write and quit and then unmount the file system.
umount /dev/hda1
Now lets make the image. In my case, I had a SATA hard drive connected to my motherboard so that I could write the image there. Feel free to write the image anywhere you like. My SATA hard drive partition was seen as /dev/sda1 by the kernel.
mount /dev/sda1 /mnt
dd if=/dev/hda of=/mnt/soekris.img bs=4k
That should be it. The image will not only include the file system, but also the MBR / boot loader. Later on, you can write the image to a new CF card using dd or windd. Take extra care that you write your image to the correct device when you do this so that you do not end up with data loss from writing to the wrong device.

Conclusion

You should now have a functional Slackware Linux distribution on your Soekris. If a newer version of Slackware comes out, I would imagine that the procedure would be around the same. The Slackware installation procedure has been about the same going several versions back now. In other future documents, I plan to cover how to setup various network devices including a GSM cell modem and Broadcom mini-PCI wireless 802.11g card via the Soekris. The Soekris has a mini-PCI slot making it simple to add a wireless card while keeping the other PCI slot free.