There are plenty of guides for doing this, but here’s my way, which I’ve done on loads of different hardware.

Personally, I prefer to use the stock debian kernel because it supports most hardware and makes upgrading through apt easier. Occasionally though, I like to test the newest kernel releases, and here’s how I do it.

1, Install necessary tools:

# apt-get install kernel-package ncurses-dev bzip2 module-init-tools initrd-tools procps fakeroot

2, Download the latest kernel source:

# cd /usr/src
# wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.22.1.tar.bz2
# tar -xjvf linux-2.6.22.1.tar.bz2
# cd linux-2.6.22.1

3, Unzip any extra patches and apply them:

# bzip2 -dc patch-xxx.bz2 | patch -p1

5, Configure the kernel.

a, Using the current config as a base:

# cp /boot/config-x.x.x /usr/src/linux-2.6.22.1/.config
# make oldconfig
[ answer all the questions]

b, Using the menu interface (you can do the cp line above to use the old config as a base but make changes):

# make menuconfig

If you have multiple processors/cores, you can speed up the compile by utilising them all (this is similar to the -j flag when compiling the non debian way). To find out the number of cores you have, run:

# grep -c ‘^processor’ /proc/cpuinfo

Then to make sure all cores are used:

# export CONCURRENCY_LEVEL=4
replace 4 with the number of processors.

6, Compile and install:

# make-kpkg clean
# time fakeroot make-kpkg –initrd –revision=1 –append-to-version=.kris kernel-image

This will usually take between 5 minutes and over an hour, depending on how many modules there are to compile, and how fast your hardware is.

Once this has finished, you will be left with a .deb file which you can install using dpkg:

# dpkg -i linux-image*.deb

Because of the –initrd flag earlier, the initrd image will be created when you install the kernel. This command will also update grub, so all you need to do to use your new kernel is reboot.