How to Recompile Linux Kernel
Posted: Tue Oct 06, 2009 3:11 pm
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.
Most people ask the reason of upgrading kernel and how to do it. 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 (like in Debian).
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.31.2.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:
Create a symbolic link for the new folder:
And then run:
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:
Finally, update your boot loader.
For instance in grub:
and edit like :
(where root changed according to your partition is mounted)
You can now reboot to your newly upgraded kernel
Most people ask the reason of upgrading kernel and how to do it. 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 (like in Debian).
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.31.2.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:
Code: Select all
tar xfvj linux-2.6.xx.tar.bz2
tar xfvz linux-2.6.xx.tar.gz (if it's gzipped)
Code: Select all
ln -s linux-2.6.xx/ linux
Code: Select all
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.
While inside /usr/src/linux type:
Code: Select all
make
Code: Select all
make modules_install
Code: Select all
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
For instance in grub:
Code: Select all
vim /etc/grub.conf
Code: Select all
title Linux (2.6.24)
root (hd0,1)
kernel /boot/vmlinuz-2.6.24 ro root=/dev/hda2 hdd=ide-scsi
You can now reboot to your newly upgraded kernel
