Defcon:Blog Keklkakl blog blag

4Mar/090

Debian Kernel compilation and installation for Sun/Cobalt RaQ

Compiling and installing a new, working Linux kernel on a RaQ appliance is not as trivial as it would be on a commodity PC/server. Here, I go through how I got my Lenny based RaQ's up and running with new kernels, starting from an already operational Debian Lenny i386 install

Prerequisites

Start off by installing the prerequisites for kernel-compilation:

apt-get install build-essential bzip2 \
    kernel-package gcc libncurses5 libncurses5-dev \
    bin86 gawk ncurses-dev initramfs-tools \
    zlib1g zlib1g-dev binutils

Download patch

Now we select, and download the cobalt patch for the Linux kernel. I like to do this _before_ downloading the kernel itself, as it allows me to see what patches exist, and select the kernel-version accordingly. I have found the -jeffw-patches to be the ones that wotk, while the -tw patches from Tim&Tina usually fail with a hang while booting. So, look over http://files.parvi.org/gentoo-stuff/patches/cobalt-kernel-2.6.x/ and find a patch for the kernel-version you wish to use((Keep in mind that Lenny uses 2.6.26 as its “native” kernel)).

wget http://files.parvi.org/gentoo-stuff/patches/cobalt-kernel-2.6.x/linux-cobalt-2.6.26.5-20081001.jeffw.patch

Download kernel

With the patch selected, and downloaded, it is time to download an appropriate kernel-source((While this may be done using apt-get, I prefer downloading it from the kernel.org source-tree)). Pick the newest subpatch-release of the patchlevel kernel you selected. E.g. if you chose the 2.6.26 kernel patch, the latest subpatch is as I write this 2.6.36.8

wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.26.8.tar.bz2

Unpack and apply patch

Unpack the kernel under /usr/src/ and move it to an appropriate name to identify that you are patching this kernel. After unpacking, apply the patch.

cd /usr/src/
tar jxvf ~/linux-2.6.26.8.tar.bz2
mv linux-2.6.26.8 linux-2.6.26.8-cobalt
cd linux-2.6.26.8-cobalt
sed -e '/^EXTRAVERSION/s/$/-cobalt/' -i Makefile
patch -p1 < ~/linux-cobalt-2.6.26.5-20081001.jeffw.patch

Download and apply base config

Next, fetch the “base-config” for the jeffw-patch. I silently ignore that Debian kernel compile recommends that you do a base in the Debian kernel config, simple because it a) includes support for a lot of hardware that the RaQ does not have, and b) the RaQ has a limitation on how large the kernel can be2). If I recall correctly, the bzip2-compressed kernel cannot exceed 1800KBytes in size.

Here, you really should select the appropriate config for your hardware.

* The RaQ3 and RaQ4, as well as most Intel Cubes are Generation III machines. * The RaQ550 is a Generation V machine.

# Generation III
wget http://files.parvi.org/gentoo-stuff/patches/cobalt-kernel-2.6.x/configs/gen_iii-minimal.config -O .config

# Generation V
wget http://files.parvi.org/gentoo-stuff/patches/cobalt-kernel-2.6.x/configs/gen_v-minimal.config -O .config

Configure the kernel

Now, we do a standard Debian kernel compilation based on the “oldconfig” that we just downloaded. We include “menuconfig” so that we can look over the config and check that we havent forgotten anything we should have included. Adjust the revision to suit your needs:

make oldconfig
make menuconfig

Debian-compile the kernel

Following the standard procedure of kernel-compilation is an option, but not a recommended one. You really should run the Debian tools for kernel compilation, as this prepares an initrd for you, does housekeeping, in addition to creating .deb packages that you can use on later installs..

make-kpkg clean
make-kpkg --initrd --revision='1' kernel_image kernel_headers modules_image

Install the new kernel

First, install the kernel at you normally would a Debian kernel package:

cd /usr/src/linux
dpkg -i linux-image-2.6.26.8-cobalt_1_i386.deb
dpkg -i linux-headers-2.6.26.8-cobalt_1_i386.deb

Next, copy the compiled kernel from the kernel source tree to /boot, strip it, and bzip2 it. This is because the RaQ does not use Grub, Lilo or such, but loads the kernel off a predetermined location, namely /boot/vmlinux.bz2. You also need to link up the initrd and the System.map

cd /boot
cp /usr/src/linux-2.6.26.8-cobalt/vmlinux .
strip vmlinux
bzip2 -c vmlinux > vmlinux.bz2
ln -s System.map-2.6.26.8-cobalt System.map
ln -s initrd.img-2.6.26.8-cobalt initrd.img
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


Trackbacks are disabled.