I usually follow the instructions at http://www.howtoforge.com/kernel_compilation_ubuntu
If you use other linux distributions please visit http://www.howtoforge.com/howtos/linux/kernel
I am listing out the instructions here for ubuntu distribution in a much simpler way. The tutorial above goes into a lot of detail. We do not usually need all the instructions listed over there. Feel free to leave comments if you have any related question unanswered or if you encounter any problems in the process. I should be able to get back to you as soon as I can.
1. It is always good to run 'sudo apt-get update' once in a while. This updates the list of packages/updates available for ubuntu. It would also be good to run 'sudo apt-get upgrade'
shell commands:
$sudo apt-get update
$sudo apt-get upgrade
2. Install the needed packages now
$apt-get install kernel-package libncurses5-dev fakeroot wget bzip2
3.If you are running recent linux distributions, you will have 2.6 kernel on it. Get the kernel source of the 2.6 kernel version you would like to compile from here
http://www.kernel.org/pub/linux/kernel/v2.6/
Go to the directory /usr/src
$cd /usr/src
Download and unzip the tarball using the command. 'version' is the linux kernel version that you want to compile
$tar -xzvf linux-
or
$tar -xjvf linux-
$cd linux-'version'
4. Create a .config file
$make menuconfig
Just leave the standard configuration (unless you know if you want a particular feature), press
If you applied any patch to the kernel, edit the '.config' file thus generated and uncomment the related config options and run
$make oldconfig
It will ask you a few questions, reply with 'm' or 'y' accordingly
5. Execute the following two commands to compile the kernel
$make-kpkg clean
$fakeroot make-kpkg --initrd kernel_headers
Now the kernel compilation will start. Be patient as the compilation may take a few hours
6. Once you notice that the compilation was successful, execute the following
$cd /usr/src
$dpkg -i linux-image-'kernel version'
$dpkg -i linux-headers-
7. Go to '/boot' directory to make sure the initrd file exists
$cd /boot
$ls -l initrd.img-'kernel version'
8. Now open the menu.lst file and check if the boot information of the new kernel version is added to the grub
$vi /boot/grub/menu.lst
find an entry for the new kernel that is installed, eg:
title Ubuntu, kernel 2.6.33
root (hd0,0)
kernel /boot/vmlinuz-2.6.33 root=/dev/sda1 ro quiet splash
initrd /boot/initrd.img-2.6.33
savedefault
boot
title Ubuntu, kernel 2.6.33 (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.6.33 root=/dev/sda1 ro single
initrd /boot/initrd.img-2.6.33
boot
9. Now restart the machine and select the kernel version you just installed, when you are on the boot screen
After the system boots execute
$uname -r
to make sure you booted with the kernel version, you just installed
Congratulations! You have just compiled and installed the linux kernel!

No comments:
Post a Comment