How to Recompile Your Linux Kernel Easily
If you are a native linux user, you have surely been in the case where you just did not need a system with just about every package there is out there. If you always wanted to know how to upgrade your kernel manually and configure what packets you need yourself, read on.
Some of you may ask “Why would i need to upgrade my kernel and what exactly is that?”. The operating system’s kernel is the basic element of your operating system and is responsible for managing various tasks, like memory management, pagination and many many more. As you can understand, the kernel includes some modules that are essential for the identification of your hardware, such as your network card and more.
The disadvantage is that the default installation of the kernel includes many more elements that what you really need. For instance, if your computer has an AMD processor, you really have no apparent reason to use the modules that the kernel includes for Intel processors.
So, there comes up a need to create your own configuration for your kernel. One more reason to do that is that you may need to have the latest kernel version on your pc, specially important if some hardware does not work with your current kernel – you may know that debian fellows
The process to upgrade your kernel is very simple. For starters head to kernel.org and download the latest stable kernel(click on F). The time that this tutorial was written, the latest one was linux-2.6.24.tar.bz2. From this point on, be a superuser(root) at your terminal.
After you download the kernel, extract it at /usr/src. Become a root with “su -” (or sudo -s and such) and extract using:
tar xfvj linux-2.6.xx.tar.bz2 tar xfvz linux-2.6.xx.tar.gz (if it's gzipped)
Create a symbolic link for the new folder:
ln -s linux-2.6.xx/ linux
And then run:
cd /usr/src/linux make mrproper make clean make menuconfig
* make mrproper erases whatever config file was existant (if there is a .config file it gets deleted).
* make clean is not essential at that point, but if you have made any previous compilations, it erases whatever changes have been made since the previous make.
* make menuconfig appears a configuration menu at the shell and from here you can add and remove any modules or built in features you need.
When you see an M near a line, this means that this component is a module and is dynamically loaded only when the kernel asks for it. On the contrary, * means that it is a built in feature and is an option that is generally a bit more harsh on your system’s speed, but it’s essential for some things. After you have selected and deselected what is important for your system, select the option “save configuration file” and save it at .config. Now at /usr/src/linux you have your new configuration file with your own choices and you are now ready to compile.
While inside /usr/src/linux type:
This will start the process of compiling your new kernel. Go grad some coffee and be back after about half an hour :p When the process ends, type :
This creates the modules for the kernel. At that point, we move the kernel and System.map at /boot with:
cp /usr/src/linux-2.6.xx/arch/i386/boot/bzImage /boot/vmlinuz-2.6.xx cp /usr/src/linux-2.6.xx/System.map /boot/System.map-2.6.xx
Finally, update your boot loader.
For instance in grub:
and edit like :
title Linux (2.6.24) root (hd0,1) kernel /boot/vmlinuz-2.6.24 ro root=/dev/hda2 hdd=ide-scsi
(where root changed according to where your partition is mounted)
You can now reboot to your newly upgraded kernel