ADAM'S WEB PRESENCE

19 March 2009

Creating a Debian Kernel Package for v2.6.26

Filed under: Nerd Notes — adam @ 10:47 am

There are so many guides out there on how to make a Linux kernel and so many of them are out of date, I thought I should write down a simple step-by-step of the current way to do it as of early 2009.

My goal here was to compile a new kernel for a Debian 4.0 (Etch) system. You can download pre-built kernels but I wanted to modify some drivers before building it.

Anyway, you will firstly need the source code. Go to the Debian Backports Repository and grab the latest linux-source package. Before installing it, you will need to install some tools:

sudo apt-get install kernel-package fakeroot libncurses5-dev

Now we can install the source:

sudo dpkg -i linux-image-2.6.26_dvc.1.2_i386.deb

cd /usr/src

tar jxvf linux-source-2.6.26.tar.bz2

ln -s linux-source-2.6.26 linux

cd linux

Next you need to configure the kernel. A good way is to simply copy the current kernel configuration:

cp /boot/config-2.6.18-6-686 ./.config

Finally, launch the make-kpkg utility. This will configure, compile and package the kernel in a DEB package.

fakeroot make-kpkg --revision=mycustomkernel-1.0 --config menuconfig --initrd kernel_image

This will launch the kernel configuration menu first. You can make any configuration changes here but usually the defaults are fine. When it is all done you will have the completed package file in /usr/src.

3 Comments »

  1. Comment by Ben — 19 March 2009 @ 4:00 pm

    I don’t know if it is documented in the kernel, but it seems to me to be a little known fact that ‘make menuconfig’ requires libncurses5-dev as you have rightly mentioned here, because the kernel compiles its configuration tool just before you invoke it, which is pretty neat.

    On the kernel config file: recent kernels have the option to stow away in the kernel image the .config file they were built with; if it’s there, just do a ‘zcat /proc/config.gz > .config’ and never misplace a kernel config ever again.

    Also, if you don’t have a problem with using a kernel.org kernel, the ‘ketchup’ tool is really nice for automagic kernel downloading and quick incremental updating.

  2. Comment by Jakob — 19 March 2009 @ 10:57 pm

    Is it possible to build the kernel with the “debuild” or the “dpkg-buildpackage” or inside “pbuilder” with the “standard” debian/rules mechanism?

  3. Comment by adam — 5 April 2009 @ 8:54 pm

    No idea, sorry.

RSS feed for comments on this post. TrackBack URI

Leave a comment


Powered by WordPress