This are the steps I followed to compile the linux kernel 2.6.35.4 on Ubuntu 10.04.
1) Download. The first step is to download the kernel at http://www.kernel.org/ and then unpack it in some location.
2) Prerequisites. Now we make sure all the necessary packets are installed:
$ sudo apt-get install fakeroot kernel-wedge build-essential makedumpfile kernel-package
$ sudo apt-get install libncurses5 libncurses5-dev
3) Configuration. Building the kernel is all about configuration. Configuring the kernel for your machine is fun but takes a lot of time and might be dangerous if you don't know what you're doing. We will take a shortcut here and use the Ubuntu configuration file for the current kernel. Go to the source directory and follow the steps bellow:
$ cd linux-2.6.35.4
$ cp /boot/config-2.6.32-24-generic .config
$ make menuconfig
In the configuration menu you can see all the options for your kernel. I only changed the processor from generic to "Core 2/newer Xeon" and the preemption model to make my computer more responsive. Fell free to explore other options. The help feature can be very useful to learn more about your computer.
4) Initramfs and initrd. Now we need a couple more tweaks before we start. First we will borrow some scripts that will help us create the initramfs file system.
$ sudo cp /usr/share/doc/kernel-package/examples/etc/kernel/postinst.d/initramfs /etc/kernel/postinst.d/initramfs
$ sudo cp /usr/share/doc/kernel-package/examples/etc/kernel/postrm.d/initramfs /etc/kernel/postrm.d/initramfs
Next we need to make sure that the initrd image is also created. To do so follow the steps below:
First create your overlay directory:
$ cp -r /usr/share/kernel-package $HOME
Now download the source code for your current kernel version:
$ sudo apt-get source linux-image-2.6.32-24-generic
This will unpack the source in $HOME/linux-2.6.32. Now copy the control scripts into your new overlay:
$ cp linux-2.6.32/debian/control-scripts/{postinst,postrm,preinst,prerm} kernel-package/pkg/image/
$ cp linux-2.6.32/debian/control-scripts/headers-postinst kernel-package/pkg/headers/
5) Parallelizing. Compiling the kernel might take a long time, like 2 hours. So if you have multiple processors in your machine you should take advantage of them to speedup the process. To do so, setup the concurrency level variable to the number of processors you have plus 1. In my case I have a core i3, with 2 processors but also with hyperthreading, so my computer sees 4 processors.
$ export CONCURRENCY_LEVEL=5
6) Compilation. Now everything should be ready for the grand compilation. Type the commands below to start compiling:
$ make-kpkg clean
$ fakeroot make-kpkg --initrd --overlay-dir=$HOME/kernel-package --append-to-version=-gbezerra kernel-image kernel-headers
Change the "gbezerra" string to whatever you want to be appended to your kernel name.
7) Installation. After 30min, depending on how many processors you have, you should have your kernel compiled and some .deb packages ready to be installed. Go to one directory above and proceed as follows.
$ cd..
$ sudo dpkg -i linux-image-2.6.35.4-gb_2010.09.10_amd64.deb
$ sudo dpkg -i linux-headers-2.6.35.4-gb_2010.09.10_amd64.deb
After that your kernel should be installed. Just to make sure, go to the /boot directory and see that all the new kernel files are there. You're ready to reboot your machine and try it out.
$ sudo reboot
Good luck!