This tutorial will explain Howto compile kernel in Debian 5.0.The default kernel that comes with Debian is better suited for servers. It's optimized for high thoughput and low interactivity. When you compile your own, you can among other things optimize it for the processor(s) you have.
Preparing Your system
First you need to install the following packages
#apt-get install kernel-package ncurses-dev bzip2 module-init-tools initramfs-tools procps fakeroot
If you plan on using the graphical configuration tools, gconfig or xconfig, you'll need additional packages, respectively libgtk2.0-dev libglib2.0-dev libglade2-dev for gconfig or libqt3-mt-dev for xconfig.
Check your kernel version using the following command
Download source using the following command
#apt-get install linux-source-2.6.26
Make directory for compiling
Copy source to newly created folder
#cp /usr/src/linux-source-2.6.26.tar.bz2 ~/newkernel/
Extract the source using the following command
#tar xjf linux-source-2.6.26.tar.bz2
You might optionally want to copy a working template for the kernel .config to this directory, you can find some in /boot/.
#cp /boot/config-$(uname -r) ./.config
Check your processor details using the following command
Configure kernel options
If you are using GNOME use the following command
If you are using gconfig you should see similar to the following screen
In the above scree you have to click on the Y/M/N letter in the very last column of your choice to enable or disable some options
Now Clean the slate for kernel compiling
If you have a multiprocessor machine, you'll want to make all processors work
Perform the actual compile, this will take anywhere from 10 minutes to 5 hours depending on your hardware and configuration choices (the more you selected, the longer it will take). You need to include kernel_headers if you want to compile some other modules against your kernel, e.g. ati or nvidia drivers.
--revision=custom.001 kernel_image kernel_headers
It then will give you all kind of chatter, warnings and notices during, it's quite normal.
Once it's done, goto the lower directory where the .deb we just created is
Install .deb package using the following command
#dpkg -i *.deb
Reboot and select from the list the new kernel with your initials or what ever ID you gave it at config time.
Source from here