Kernel is the core of the operating system .Linux Kernel mainly comprises of some million lines of code written in C language. It carries out various tasks which include scheduling, Multitasking, Multiprogramming, access to a shared memory and much more. Linux Kernel is Open source and thus the code is available to the public freely. It is this feature which makes Open Source products superior than the closed source ones. With Open Source Products people are given the freedom to modify or remove the parts of the Kernel program and Build and Compile their own Kernel .
Before starting of our journey to the Kernel compilation and Building, we need to have the Latest stable release of the Linux kernel.To download the Latest Linux kernel ,Visit the website www.kernel.org .
Download the stable release which is 126.96.36.199 as of this date. There are even available release candidate of the upcoming versions of Linux kernel (2.6.37.rc7).
After downloading the Linux kernel into your home folder, the downloaded file will be in .tar.bz2 format.Extract the file using tar command as
# tar xvfz linux-188.8.131.52.tar.bz2
or by right clicking the file and choosing the option "Extract here" .
After extracting the .tar.bz2 file ,the folder containing various Linux kernel program files will be available.Modify the Linux kernel programs as per your wish.After Modifications we are ready to compile and Build the Linux Kernel.
Switch to super user mode by issuing "su" command before proceeding further .
Compilation and Building of your own Linux Kernel can be achieved by following these simple steps.
- Copy the extracted Linux kernel folder into /usr/src using the following command.Copying of the files into the root directory may be prohibited . To get the write permission to the root use chmod to change the permission settings . Enter the directory as cd /usr and issue the following command chmod -R 777 * forgranting the write permissions.
# cp linux-184.108.40.206 /usr/src
- Compilation of the Linux kernel needs gcc compiler, to install gcc if not available issue the following command at the terminal :
# apt-get install gcc
- Download and install the libncurses5-dev library which is used for graphical display during configuration phase of the Linux kernel compilation.
# apt-get install libncurses5-dev
- After achieving all the pre-compilation steps mentioned above,we are now ready to compile the kernel code. Move into the /usr/src/linux-220.127.116.11 directory by issuing the following command.
# cd /usr/src/linux-18.104.22.168
- Issue any one of the following command for getting the configuration menu .
# make menuconfig
# make xconfig
# make gconfig
Configure the different options to be included during the compilation here.
- To start compiling and create a compressed image of the linux kernel issue the command :
To start compiling the kernel modules issue the command
# make modules
- Now install the Kernel modules as
# make modules_install
To install the whole of the Linux Kernel compiled issue the command :
# make install
- It will install three files into your /boot directory which include as well as modified configuration file to your grub folder. Move into the /boot directory as cd /boot
- The next step is to create and initrd image in the /boot directory using mkinitrd or mkinitramfs command as follows.
# mkinitrd -o initrd.img-22.214.171.124 126.96.36.199
# mkinitramfs -o initrd.img-188.8.131.52 184.108.40.206
initrd contains device drivers used to load your operating system later.
- In this step we need to make an entry into the grub configuration file located in /boot directory.
# gedit grub/menu.lst
Make the following entry into the menu.lst configuration file.
title Debian GNU/Linux, kernel 220.127.116.11 Default
kernel /boot/vmlinuz root=/dev/hdb1 ro
Save it and Exit.
To automatically update the grub for new lines in the kernel issue the command
- Reboot your computer .
On Reboot select the option with the version of the Linux Kernel you compiled and here you are with your own Linux kernel which works just the way you configured.
Any problems or Suggestions do feel free to leave a comment or mail me at firstname.lastname@example.org