Debian-Kernel-Compile-Howto (Kernel 2.6)

Debian-Kernel-Compile-Howto (Kernel 2.6)

Version 1.1
Author: Falko Timme

In some cases you might want to compile your own kernel that suits your needs better than the standard kernel that comes with your distribution. I will describe how to do this on a Debian Woody machine (a description for Debian Sarge can be found here!). Please note that this tutorial is for kernel 2.6 only! A tutorial for kernel 2.4 can be found here.

Be aware that there is some risk in doing so! For example, it could happen that your machine does not boot properly after you have installed the new kernel so you might be forced to boot from a rescue CD to repair your system. You have been warned! This document comes without warranty of any kind!


First login to your Debian machine on the command line as root. Install the prerequisites that we need to compile the new kernel:

apt-get install kernel-package ncurses-dev fakeroot wget bzip2

Then go to /usr/src:

cd /usr/src

Then get the latest Linux kernel source (or the kernel source you need) from


Unpack the kernel sources:

tar xjf linux-

cd linux-

It is normally a good idea to take the configuration of your existing (working!) kernel 2.6 as a starting point for the configuration of your new kernel. Usually the current kernel configuration is saved in a file under /boot, e.g. /boot/config-2.6.3. We will load this configuration and then do the changes we desire. If you do not have the config file of a working kernel 2.6 this one might help you.

make menuconfig

Select Load an Alternate Configuration File and enter the location of the configuration file of your current kernel (or upload my kernel configuration to your machine and enter its path):

The configuration of your current kernel will be loaded, and you can now browse through the menu and change the configuration to suit your needs. When you are finished, save your new kernel configuration:

Then run the following commands (please note that make dep is not needed any more for kernel 2.6):

make-kpkg clean
fakeroot make-kpkg --revision=custom.1.0 kernel_image

If the compilation stops with an error, run

make clean

and then re-run the previous commands starting with

make menuconfig

Change the kernel configuration where the error occurs. If no error occurs you will find the new kernel as a Debian package called kernel-image- under /usr/src.

cd ../

Now you have to install some packages that are needed by kernel 2.6. Add the following line to /etc/apt/sources.list:

deb woody module-init-tools initrd-tools procps

Then run:

apt-get update
apt-get install module-init-tools initrd-tools procps

If you are asked the following question:

"If you really want to remove modutils type 'yes':"

type yes.

It might also be necessary to update packages like bind9, quota, etc. - depending on your configuration. If you have problems with your existing packages try to get the appropriate package from

Install your new kernel:

dpkg -i kernel-image-

Create a ramdisk of your new kernel (otherwise your system will most likely not boot):

cd /boot/
mkinitrd -o /boot/initrd.img-

We are almost finished now. Edit the image=/vmlinuz stanza of your /etc/lilo.conf and add the line initrd=/boot/initrd.img-

# Boot up Linux by default.

#        restricted
#        alias=1



to update your boot loader and reboot your machine:

shutdown -r now

and if everything is ok your machine should come up with the new kernel. You can run

uname -a

to verify that. Good luck!


This is an excerpt from an email that R (Chandra) Chandrasekhar (thanks a lot for this one!) sent to me regarding the kernel configuration in case you use flash drives and nVidia cards:

"1. If you intend to use flash drives, de-select the following during <make xconfig>:

Block Devices -> Low Performance USB Block driver (BLK_DEV_UB)

There is a clear explanation at and at on why this is advisable until further development of the ub module.

I had to

apt-get install udev hotplug

to use the flash drive, but it worked like a charm after that!

2. If you have an nVidia card, de-select the following during <make xconfig>:

Graphics Support -> nVidia Riva support (FB_RIVA)

Kernel Hacking -> Use 4Kb for kernel stacks instead of 8Kb (4KSTACKS)

Processor Type and Features -> Local APIC support on uniprocessors (X86_UP_APIC)

To install the nVidia drivers, I followed the HOWTO at and compiled the drivers from the Debian packages after applying the vmalloc_reserve.patch during kernel build."

Share this page:

Suggested articles

7 Comment(s)

Add comment



Hello, everyone. This is very good and precise instructions. However, I ran into a problem. After installing the new kernel (2.6.12), I ran the mkinitrd -o initrd.img-2.6.12 2.6.12. It does not create the initrd.img. Thus, the new kernel is useless, it could not boot up (missing the file). Does anyone know what the problem is? Please advise. Thanks. TJ


mkinitrd -o /boot/initrd.img-2.6.12 2.6.12

should work


That worked. It is very interesting. I was under the boot directory when I issued mkinitrd -o initrd.img-2.6.12 2.6.12 Anyhow,it still wants the full path to boot. Thanks

By: Anonymous

Hi, mkinitrd changes current directory when it runs. So the final initrd image when you run without to specify exact directory places your image somewhere else.


By: Anonymous

Why don't just make deb-pkg and installl the compiled dpkg?


By: Anonymous

I wanted to compile a 2.6.14 kernel (the newest when I was recompiling).

Additional steps I took :

* sudo apt-get install libqt3-mt-dev

This step allows you to do "make xconfig" (graphical configuration) instead of "make menuconfig". However, bear in mind that if you executed "su" (or "sudo") to become root, you have to : "su <user from which you became root>" and then "xhost +". Otherwise the root user won't be able to use the normal user's graphical session. (Ctrl + D to exit normal user and become root again)

* sudo apt-get install yaird

The 2.6.14 kernels do not use devfs anymore, so the old initrd tools don't work for installing the kernel (you can take this step after the kernel compilation. It just has to be done before "dpkg -i kernel-image-..."

By: porkcharsui


 Can anyone help me with the following please?! I follow these instructions(howto_linux_kernel_2.6_compile_debian) to the letter, on a freshly installed pc(the only thing that has been done on the pc after install, are the before mentioned instructions), but the kernel will not compile! The following is what happens after make menuconfig:

# configuration written to .config

*** End of Linux kernel configuration.
*** Execute 'make' to build the kernel or try 'make help'.
[email protected]:/usr/src/linux$ sudo make-kpkg clean
exec make -f /usr/share/kernel-package/ruleset/ clean
====== making target minimal_clean [new prereqs: ]======
test ! -f .config || cp -pf .config config.precious
test ! -e stamp-building || rm -f stamp-building
test ! -f Makefile || \
            make    ARCH=i386 distclean
make[1]: Entering directory `/usr/src/linux-2.6.29'
  CLEAN   scripts/basic
  CLEAN   scripts/kconfig
  CLEAN   include/config
  CLEAN   .config .config.old include/linux/autoconf.h
make[1]: Leaving directory `/usr/src/linux-2.6.29'
test ! -f config.precious || mv -f config.precious .config
rm -f modules/modversions.h modules/ksyms.ver conf.vars scripts/cramfs/cramfsck scripts/cramfs/mkcramfs applied_patches  stamp-build stamp-configure stamp-image stamp-headers stamp-src stamp-diff stamp-doc stamp-manual stamp-patch stamp-buildpackage stamp-debian
[email protected]:/usr/src/linux$ sudo fakeroot make-kpkg --initrd
exec make -f /usr/share/kernel-package/ruleset/ debian  INITRD=YES
====== making target minimal_debian [new prereqs: ]======
This is kernel package version .
test -d debian || mkdir debian
test ! -e stamp-building || rm -f stamp-building
test -f debian/control || sed         -e 's/=V/'        \
                -e 's/=D/'         -e 's/=A/i386/g'  \
                -e 's/=SA//g'   -e 's/=L/ /g' \
                -e 's/=I//g'                                    \
                -e 's/=CV/2.6/g'                       \
                -e 's/=M/Unknown Kernel Package Maintainer <[email protected]>/g'                        \
                -e 's/=ST/linux/g'      -e 's/=B/i386/g'    \
                         /usr/share/kernel-package/Control > debian/control
test -f debian/changelog ||  sed -e 's/=V/'             \
            -e 's/=D/'        -e 's/=A/i386/g'       \
            -e 's/=ST/linux/g'     -e 's/=B/i386/g'         \
            -e 's/=M/Unknown Kernel Package Maintainer <[email protected]>/g'                        \
             /usr/share/kernel-package/changelog > debian/changelog
install -p -m 755 /usr/share/kernel-package/rules debian/rules
for file in ChangeLog  Control  Control.bin86 config rules; do                                      \
            cp -f  /usr/share/kernel-package/$file ./debian/;                               \
for dir  in Config docs examples ruleset scripts pkg po;  do                                      \
          cp -af /usr/share/kernel-package/$dir  ./debian/;                                 \
test -d ./debian/stamps || mkdir debian/stamps
exec debian/rules  INITRD=YES
nothing to be done.

This is what I get at the end... "Nothing to be done.", and then there are no *.deb files in /usr/src/ for me to install. What am I doing wrong? Who can help me?