Saturday, 17 January 2009

How to really build a nice Debian kernel package in a clean way

There are a lot of manuals around. So why do I want to add another? Because I want to eliminate some not so clever hints and remarks. First and most importantly of all: there is NO step which has to be done as root in the whole kernel package building process (provided that the necessary tools are installed). I do it as me, ben.
Many of the following steps can be replaced by GUI action. There is no reason not to use the GUI, e.g. file-roller for extraction etc. I will give the commands, anyway.

Let's get started by installing some necessary tools. If you encounter other packages which are not installed on a typical Debian/Ubuntu/gNewSense system, please let me know.

ben@bearfoot:~$ sudo -s
root@bearfoot:~# apt-get install fakeroot kernel-package build-essential libncurses5-dev
root@bearfoot:~# exit

We will work in the directory ~/kernel:

ben@bearfoot:~$ mkdir kernel
ben@bearfoot:~$ cd kernel

Download the sources for a free kernel at
, e.g.:
ben@bearfoot:~$ wget -c
ben@bearfoot:~$ tar -jxf linux-2.6.28-libre.tar.bz2
ben@bearfoot:~$ cd linux-2.6.28

The next step will enable you to use an existing kernel configuration as a base for your new config:
ben@bearfoot:~$ cp /boot/config-{your-latest-version} ./.config
ben@bearfoot:~$ make menuconfig
ben@bearfoot:~$ fakeroot make-kpkg clean
ben@bearfoot:~$ fakeroot make-kpkg buildpackage --initrd --append-to-version=-libre-ben --revision 20090117

The execution of the last command may take a lot of time, depending on your machine, your kernel configuration and what you do on the machine during compile time. On a Pentium 4 2.4GHz with 1.5GB RAM running gNewSense it took about... well, it is not finished yet. Will tell you next time.


Tu said...
This comment has been removed by the author.
Camelek said...

There is no package named "kernelpackage", please change that to:
"kernel-package" :]
Thank you for your article about Debian custom kernel instalation :]

ben said...

thanks for your remark. i changed the package name in the article.