Compile a new kernel on Debian

Debian Squeeze (or 6) is shipped with Linux kernel 2.6.32. However, back in November 2010, Phoronix announced a wonderful patch for the kernel which includes 200 lines of magic: they reduce the maximum latency by 10, and the average latency by 60. It is now integrated in the 2.6.38 kernel: we’ll see how to compile & install it on Debian.

First of all, you’ll need to install the following packages: fakeroot, kernel-package and the kernel source code.

1. Install the packages fakeroot, kernel-package and download the kernel source code.

2. Extract the kernel source code to /usr/src/.

3. Inside the kernel source code directory, open a terminal and type make xconfig to configure the kernel in a window or type make menuconfig (dependency: libncurses5-dev required) if you want a basic configuration menu in the terminal. The kernel default configuration works perfectly on my Debian PC, but you may want to configure it to suit your needs.

4. Once this is done, use make-kpkg clean to clean the source tree & reset the kernel-package parameters.

5. Compiling time! You must be the root user, so check twice before you do anything. Type fakeroot make-kpkg –initrd –revision=custom.1.0 kernel_image. You can change the “1.0” at will: it’s just used to keep track of your own kernel builds. Compiling takes a lot of time, i.e. 2-3 hours, so wait patiently.

6. We’ve now got an image of the kernel as a .deb package. Make sure you’re in the directory containing the image, and type dpkg -i linux-image- The subarchitecture part is an optional sub-architecture, such as “686”, depending on what kernel options you set; if you use the default configuration, just type dkpg -i linux-image-

7. Reboot and see if you have any error messages (unlikely to happen).

8. (Optional) Make sure the kernel has been updated: type uname -r in a terminal, it should return

Nota bene: I know backport packages have been released for the 2.6.38 kernel, but this will work with -any- kernel, so you don’t have to wait for backport packages when there aren’t.

There is another way to compile the kernel, which simply consists in using make deb-pkg in the kernel source code directory; this article only explains how to compile it the “Debian way”.

Last but not least, I am not responsible for any damage done to your computer. There’s no reason to have any problem except if you haven’t properly followed the steps.

Original article: Compiling a New Kernel — Retrieved and shortened.


"Knowledge is power. Information is liberating." - Kofi Annan. I love messing with stuff. The result's always awesome!

Tagged with: ,
Posted in GNU/Linux
2 comments on “Compile a new kernel on Debian
  1. icwiener says:

    It’s “make menuconfig” not “make makeconfig” and the depencency is “libncurses5-dev” not “libcurses5-dev”.

    Is step 4 (the make-kpkg clean) really necessary?

  2. iceTwy says:

    Thanks for your comment. I’m correcting them right now.

    make-kpkg clean can be skipped, but it’s still more careful to do it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: