Download the Kernel Sources
First of all, you need to download the required kernel to /usr/src. Visit www.kernel.org and decide the kernel you want to install. For example linux-18.104.22.168.tar.bz2.
After that, you need to unpack the kernel sources and develop a symlink linux to the kernel sources directory:
tar xjf linux-22.214.171.124.tar.bz2
ln -s linux-126.96.36.199 linux
Apply patches to the Kernel Sources (Optional)
At times, you want drivers for hardware that aren’t supported by the new kernel by default, or you require support for virtualization methods or some other latest technology that hasn’t introduced in the kernel yet.
Now let’s suppose you have downloaded the required patch (it is named as patch.bz2 in this example) to /usr/src. Given below is the procedure of applying it your kernel sources.
bzip2 -dc /usr/src/patch.bz2 | patch -p1 --dry-run
bzip2 -dc /usr/src/patch.bz2 | patch -p1
The command written on the first line is just a test, it has nothing to do with your sources. If it is free from any type of errors, run the second command which is used in applying the patch. Make sure if the first command show errors then don’t proceed further.
In case your patches are compressed with gzip (.gz) in its place of bzip2(.bz2), then you patch your kernel according to this method:
gunzip -c /usr/src/patch.gz | patch -p1 --dry-run
gunzip -c /usr/src/patch.gz | patch -p1
There is also an option of applying kernel perpatches to your kernel sources. For example, there is something which is only available in kernel 2.6.19-rc6 and you need it urgently, but the full sources haven’t been launched yet for this kernel. There is a patch -2.6.19-rc6.bz2 is available, and there is an option of applying that patch to the 2.6.18 kernel sources, but not to kernel 188.8.131.52 or 184.108.40.206 or 220.127.116.11, etc. You can get further details about it on http://kernel.org/patchtypes/pre.html:
So in order to compile a 2.6.19-rc6 patch to kernel 2.6.18, follow this procedure;
bzip2 -dc /usr/src/patch-2.6.19-rc6.bz2 | patch -p1 --dry-run
bzip2 -dc /usr/src/patch-2.6.19-rc6.bz2 | patch -p1
Configure The Kernel
It is better to apply the configuration of your present working kernel as a basis of your new kernel. So, you have to copy the current configuration to /usr/src/linux;
make clean && make mrproper
cp /boot/config-`uname -r` ./.config
Then we run
This will open kernel configuration menu. Go to Load an Alternate Configuration File and select .config(which has the configuration of your present working kernel) as the configuration file:
After that browse through the configuration menu and select the options. Make sure to mention a kernel version identification string under General Setup ---> () Local version - append to kernel release. In this tutorial, we have used –default so the kernel rpm package is identified as kernel-18.104.22.168default-1.i386.rpm. String can also be left blank or you can mention a different one in order to specify the kernel such as –custom.