How to build a kernel or kernel module for your experiment

Requirement / Prerequisite

  • Extra x86 machine running Debian distribution or other derivatives such as Knoppix and Ubuntu
  • Several GB of disk space
  • Install the packages needed for compiling a kernel:
  apt-get install kernel-package ncurses-dev fakeroot wget bzip2 sharutils devscripts

Getting Voyage Kernel Source

Download the voyage kernel-source debian package from the following location:
http://www.voyage.hk/dists/0.6/linux/

For example, wget and install the kernel-source package by running "dpkg -i <kernel-source.deb>", something like:
wget http://www.voyage.hk/dists/0.6/linux/linux-source-2.6.26-voyage_6.0-2_all.deb
dpkg -i linux-source-2.6.26-voyage_6.0-2_all.deb

Setting up Kernel Source Tree

Extracting kernel source tarball

By either method, it will install the kernel source tarball to /usr/src. Extract the tarball by:

  cd /usr/src
  tar -jxf linux-source-2.6.26-voyage.tar.bz2

This will extract the voyage kernel source to linux-source-2.6.26-voyage

Downloading kernel configuration

Download the corresponding kernel config file from voyage.hk and put to /usr/src:

  wget http://www.voyage.hk/download/kernel_config/config-2.6.26-486-voyage_6.0-2
  cp config-2.6.26-486-voyage_6.0-2 linux-source-2.6.26-voyage/.config

Kernel configuration files can be found at http://www.voyage.hk/download/kernel_config/

Patching kernel

You can now apply your own kernel patch to voyage kernel, here are the commands I use:

  cd kernel-source-2.6.26-voyage
  patch -p1 < <my patch>

Look at the output to see if the patch is rejected.

(some of the later patches had to be applied with -p4 instead of -p1. ill-diffing?)

Building Kernel

Enable kernel module and drivers

Most of the time, you will want to enable some modules compiled for the kernel. If so, run:

make menuconfig

find the module and enable it.

Building Debian kernel image

in the kernel source, edit debian/changelog and change the first line to:

linux-source-2.6.26-voyage (6.0-2Custom) unstable; urgency=low

then edit debian/control and change the line:

Package: linux-image-2.6.26-voyage

to

Package: linux-image-2.6.26-486-voyage

To build debian kernel image:

make-kpkg --revision="6.0-2Custom" --append-to-version "-486-voyage" kernel-image --rootcmd fakeroot --initrd

This is the command that will build the voyage kernel. You may want to modify the --revision and --append-to-version flags to specify the different revision and version of your choice.

Read the output to see if the compilation fails. If no error spotted, the new debian kernel package can be found in /usr/src/. The kernel image should be named like kernel-image-2.6.26-486-voyage-6.0.2Custom_i386.deb.

In some cases, if you have some compile problem, you could do a 'make' in the root of kernel-source and then do a debian style make-kpkg:

fakeroot make-kpkg --append_to_version -486-voyage --revision=6.0-2Custom kernel_image --initrd

this way has worked for me..

Installing the kernel

copy the .deb package created in the previous step to the testbed node running Voyage and install it with dpkg -i

Remember to upgrade grub after the installation of the new kernel:

update-grub