Friday, January 15, 2010

What is kernel compilation in Linux & How can do in RHEL5

What is kernel Compilation:
Linux is not a user friendly operating system, however it is more flexible than other operating systems. So you can tune the kernel to the desirable style for better performance to work with new hardware or network as well as new configurations with the existing hardware or network.

Kernel compilation has the following 8 steps to do:
1. Download the latest kernel from http://kernel.org
# cd /tmp
# wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-x.y.z.tar.bz2
2.Extract the compressed file into the specified directory It is usually /usr/src/
  # tar -xjvf linux-2.6.25.tar.bz2 -C /usr/src
  # cd /usr/src

3.Install gcc package through yum in RHEL5
  # yum install gcc
You can use anyone of these commands for compiling the kernel in your desirable style
  • # make menuconfig - Text based color menus, radiolists & dialogs. This option also useful on remote server if you wanna compile kernel remotely.
  • # make xconfig - X windows (Qt) based configuration tool, works best under KDE desktop
  • # make gconfig - X windows (Gtk) based configuration tool, works best under Gnome Dekstop.
  # make menuconfig
4.Compile kernel
    Start compiling to create a compressed kernel image, enter:
    # make
    Start compiling to kernel modules:
    #make modules
    Install kernel modules (become a root user, use su command):
   # make modules_install
  # make install
 5. Install kernel
    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
6. Create on image
  # cd /boot
  # mkinitrd -o initrd.img-2.6.25 2.6.25

7. Modify Grub configuration file - /boot/grub/grub.conf
  title           Redhat Enterprise Linux, kernel 2.6.25 Default
  root            (hd0,0)
  kernel          /boot/vmlinuz root=/dev/hdb1 ro
  initrd          /boot/initrd.img-2.6.25

The following are not commands in the file.These are steps in the kernel compilation.
  savedefault
  boot
8. Reboot the system and boot into your new kernel that you have compiled just now 
    # reboot

0 Comments: