Compiling Linux Kernel, according to a popular myth, is a very tough job. Personally I find it really easy and I'll walk you step by step through this process. I am using Fedora 13 KDE for the compilation.
Before building your kernel I would advice you to backup your data and grub.conf.
- Download the source from http://kernel.org. The convention is that that even numbered sources like 2.2, 2.4, 2.6 etc are stable while odd numbered like 2.3 and 2.5 are not suited for production environment. I am using kernel 2.6.37 for this tutorial.
- Assuming that you have placed your source on /usr/src/, extract the kernel source form the archive using the following command: tar xvjf linux-2.6.37.tar.bz2
- Now, it is a good practice to clean the build area before any compilation. make mrproper
- Let us start with the configuration now. Kernel source comes with several configuration tools to make your life easier. I will use xconfig but a GNOME user might want to go for gconfig. make xconfig
- Now select the modules and features you want your kernel to have. I would recommend checking Loadable Module Support. I also got rid of all Mac driver since I use a Dell. Likewise you can strip down your kernel easily. Save the file once you are done.
- Once we got the .config file we should go to the Makefile and add a customization marker to differentiate my kernel from the default ones. I'll assign a value to the variable EXTRAVERSION in the Makefile. For me it was EXTRAVERSION = -aditya.
- Now just run the make command and be patient. It took my machine around 2 hours for the compilation. I am running an Intel Core 2 Duo and 3 Gig of RAM.
- Once the kernel is compiled install the modules. make modules_install
- Now I would copy my kernel and the system map to the /boot. cp /usr/src/linux-2.6.37/arch/i386/boot/bzImage /boot/vmlinuz-2.6.37-aditya
cp /usr/src/linux-2.6.37/System.map /boot/System.map-2.6.37-aditya
- Run the new-kernel-pkg to create the list of module dependencies, update grub.conf etc.new-kernel-pkg -v --mkinitrd --depmod --install 2.6.37-aditya
Update: Please check out the comments for some cool tips.