How to: Compile Linux kernel
Compiling Cutom Kernel is Fun activity. Serially Its own advantages and disadvantages.
However, Beginner / sometimes admin find it difficult to compile Linux kernel. Compilation needs to be understand before typing any command.
Here is the steps by step Information:
Step # 1 Download the Latest Linux kernel tar ball.
#cd /home/shihora/
#wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-x.y.z.tar.bz2
Step # 2 Extract tar file
# tar -xjvf linux-x.y.z.tar.bz2 -C /usr/src
# cd /usr/src
Step # 3 Configure kernel
Before you configure kernel make sure you have development tools (gcc compilers and related tools) are installed on your system.
# yum install gcc
Now you can start kernel configuration by typing any one of the command:
# 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
For example make menuconfig command launches following screen:
# make menuconfig
You have to select different options as per your need. Each configuration option has HELP button associated with it so select help button to get help.
Step # 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):
#su -
#make modules_install
Step # 5 Install kernel
So far we have compiled kernel and installed kernel modules. It is time to install kernel itself.
# make install
It will install three files into /boot directory as well as modification to your kernel grub configuration file:
System.map-x.y.z
config-x.y.z
vmlinuz-x.y.z
Step # 6: Create an initrd image
Type the following command at a shell prompt:
# cd /boot
# mkinitrd -o initrd.img-x.y.z x.y.z
initrd images contains device driver which needed to load rest of the operating system later on.
Step # 7 Modify Grub configuration file - /boot/grub/menu.lst
Open below file using vi:
# vi /boot/grub/menu.lst
title Debian GNU/Linux, kernel 2.6.25 Default
root (hd0,0)
kernel /boot/vmlinuz root=/dev/hdb1 ro
initrd /boot/initrd.img-2.6.25
Remember to setup correct root=/dev/hdXX device. Save and close the file.
Step # 8 : Reboot computer and boot into your new kernel
# reboot
Thats it Guys .. Isn't it fun activity :)
No comments:
Post a Comment