Friday, 12 August 2011

How to Compile Linux Kernel and Installing a different Kernel in your System


Compiling the Linux Kernel is very easy , it needs to understand few things and some couple of commands.

# :-   super user(root)
$  :-  Normal User
Steps are as follows :

Step 1:
download the linux kernel code from the site(i will suggest www.kernel.org).
File name would be linux-x.y.z.tar.bz2, where x.y.z is actual version number.
For example file inux-2.6.25.tar.bz2 represents 2.6.25 kernel version.

Step 2:
Extract the tar file and put it inside /usr/src
$cp linux-x.y.x.tar.bz  /usr/src
$cd /usr/src
$tar -xjvf  linux-x.y.z
$cd linux-x.y.z

Step 3:
Configure the kernel according to your needs:
$make menuconfig

Step 4:
run the command
$make dep

Step 5:
$make
it will compile the kernel.

$make modules
it will compile the kernel modules

Now install the kernel modules
#make modules_install

Step 6:
Now we will install the kernel by using

#make install

It will install three files into /boot directory as well as modification to your kernel grub configuration file:

System.map-2.6.25
config-2.6.25
vmlinuz-2.6.25

Step 7:

Now we will create initrd image.
#mkinitramfs -o initrd.img-2.6.38.3 2.6.38.3

2.6.38.3 is kernel version

Step 8:
run the following command to update the grub.cfg file.
# update-grub


Step 9:
#reboot
Now reboot your system into your new kernel.

No comments:

Post a Comment