Tuesday 28 July 2009

compile linux kernel yourself

Download a kernel source code ,if it is a compressed source code decompress it and then enter the directory.
To configure your kernel according to your needs you can type any of the following commands
* make menuconfig (ncurses based )
* make config (text based)
* make Xconfig (X11 based)
* make gconfig (gui based).
After configuring the kernel u can type makedep (if u r using kernel source less than or equal to 2.4 else this step is not needed),
then type the command makebzImage (if u r using kernel source less than or equal to 2.4 else this step is not needed)then type make modules (if u r using kernel source less than or equal to 2.4 else this step is not needed) if you r using 2.6 kernel then you can avoid steps after make menuconfig
and just type make -j2 or j4 according to the no of processors
after this step just type the command make modules_install then make install
Now a kernel image will be formed in the /boot directory
if no initrdimg if formed for the new kernel just make it manualy by the command mkinitramfs /tmp/initrd[version].img [version]
now type cp /tmp/initrd[version].img /boot
Now we shall edit the grub as
title name of the kernel
root (hd0,X)#where x is the partition no of your root filesystem minus 1
kernel vmlinuz[version]
initrd intrd[version].img