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

4 comments:

  1. helpful...thanx

    ReplyDelete
  2. oh nice daaa!!!love u daaa!!!

    ReplyDelete
  3. very nice!!!!

    ReplyDelete
  4. i have some problem with making the initrd image for my linux kernel version 2.6.26.1. i have successfully compiled and installed the kernel but i could not make the initrd.img.2.6.36.1. i tried the command mkinitramfs but it creats the following error
    touch: cannot touch `/root/tmp/initramfs-2.6.36.1': No such file or directory
    /usr/sbin/mkinitramfs: 351: cannot create : Directory nonexistent
    E: mkinitramfs failure find 141 cpio 141 gzip 2

    ReplyDelete