Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
Site Navigation
Linux Forums
Linux Articles
Product Showcase
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Free Publications

Step by step commands used for rebuilding the linux kernel. This article is applicable for RedHat Enterprise Linux 3

How to Rebuild linux kernel

A complete reference for rebuilding the Linux kernel for Red Hat Enterprise Linux-3


The part of the OS, which handles all the details of sharing resources and device handling, is the kernel (core OS). The kernel is not something which can be used directly. The kernel services can be accessed through system calls. A user interface or command line interface (CLI), allows users to log onto the machine and manipulate files, compile programs and execute them using simple commands. Since this is a layer of software which wraps the kernel, it is called a shell around the kernel.Kernel versions:

There are four Level or parts of Linux kernel version.

Eg:       kernel 2.4.21.-4.EL

First part:   Major version of kernel that is-(2).

Second part:  Minor version of kernel that is-(4).

Third part: Patch or Developmental version that is (21) and

Fourth part:  Extra version that is (-4.EL).

Major version of kernel:

Major version will be changed after many several years and it provide significant improvements in the Kernel capabilities and performance.

Minor versions:

Minor version is release more frequently than the major version.  Software does not generally need to be reconfigured or modified to work with a new minor version of a kernel.
When small softwares will added in the kernel then minor version will be changed.
When minor number is odd then that kernel will be unstable, and when minor number is even then the kernel version will be stable.
Eg:  2.3, 2.5- is unstable version (Beta version).
        2.4, 2.6-is stable version.

It will be changed when smallest software will be added on your system.

This is just like the service pack of windows.

Extra version:

It will display the extra facility of the Linux that means it display which type of kernel model is running on your computer.

Eg:  2.4.21-4.EL        Simple kernel with simple processor.
       2.4.21-4.ELsmp    Advance kernel with core to dual processor.
2.4.21-4.ELbigmem    when the size of RAM is up to 4GB.
2.4.21-4.ELhugemem   when RAM is between 8GB-4GB.


<span style="font-style:italic;">1. Monolithic Kernel</span>: 

Slow booting
Fast execution
Kernel program will be written in single file.

2. Modular kernel:

Fast booting.
Slow execution.
Kernel program will be written in many functions and all are called by the main function.

For more details visit

Kernel related files:

Linux kernel requires several supported files.
a. Boot files:  Needed for boot the system.
b. RPM package files:  Needed to install or build a kernel.

Kernel boot files:

The Linux boot files resides in the /boot file system, so that they can be accessed by system BIOS code that is incompatible of accessing every sector on the large hard disk.
There files are

1. Vmlinu*
It is a Linux kernel bootable file.
It is a arbitrary name of vmlinux and vmlinuz.

2. Boot.b :   Boot.b  is a second stage boot loader.

3. Initrd:     Initrd is RAM disc file that contains drivers or modules, available to be kernel at boot times.
It is open use or needed to boot from a SCSI hard drive or SATA hard drive.
It is not generally needed for normal system operation.

4. Boot.nnnn :  It is a backup copy of original master record.

5. System.map:  A file needed by the utility that read the /proc file system and used to debug the kernel.

Kernel panic:

 Kernel panic message are rare and are usually due to a miss configuration problem, missing modules, fail to load a module, using the hardware which are not supported by the current kernel version.
Kernel panic
Kernel panic
In Linux, a "panic" is an unrecoverable system error detected by the kernel as opposed to similar errors detected by user space code. It is possible for kernel code to indicate such a condition by calling the panic function located in the header file sys/system.h. However, most panics are the result of unhandled processor exceptions in kernel code, such as references to invalid memory addresses. These are typically indicative of a bug somewhere in the call chain leading to the panic. They can also indicate a failure of hardware, such as a failed RAM cell or errors in arithmetic functions in the processor caused by a processor bug, overheating/damaged processor, or a soft error.

<span style="font-weight:bold;">
Required packages for rebuilding the new kernel:</span>

                  # rpm  -qa|www.linuxhq.com|www.linuxhq.com|www.linuxhq.com|www.linuxhq.com|www.linuxhq.com|www.linuxhq.com|www.linuxhq.com|www.linuxhq.com|grep  kcc.

Step by step command used for Rebuilding the kernel:

Notes:  By using these commands we can only rebuild the kernel for Red Hat Enterprise Linux-3.

Run the following commands in sequence as a root user.
              #  cd  /usr/src
              #  ls
              # cd linux-2.4
              # ls
              # vi  makefile
               Version = 2
               Patchlevel = 4
               Sublevel = 25
               Extraversion  = -5.ELAKKI    (any name as AKKI).


To copy old kernel configuration file

         # cp  p   configs/kernel-2.4.21-i686.config   arch/i386/defconfig
         #  y    (then press enter)
         # make  mrproper

For removing unused kernel files and directories and create new file and directory for new kernel.

            # make   oldconfig

To save old kernel configuration file in running mode. If it display   yes/no option then reboot the system and then re-run the above commands.
Please keep patience after running this command since it might be take 4-5 hours to complete the process,

                  #  make menuconfig
Text based color menus, radiolists & dialogs. This option also useful on remote server if you wanna compile kernel remotely.
              # make    dep   bzImage   2>errors
              # ls

 Vmlinux ,  system.map    if we get these two files here  that means we are going in right direction and if not that mean there is some problem with it. And we have to rebuild it again until and unless these two files are not present here.

To see bzImage

      # ls   -l  arch/i386/boot/bzImage

 To create kernel moduel.
            # make modules
            # make   modules_install
            # cp  -p arch/i386/boot/bzImage   /boot/vmlinuz-2.4.25-5.ELAKKI

            # cp  -p System.map /boot/System.map-2.4.25-5.ELAKKI

            # mkinitrd  -v  -f   /boot/initrd-2.4.25-5.ELAKKI.img    2.4.25-5.ELAKKI

Configuration of  Grub:

              # vi  /boot/grub/grub.conf
            ( Add for the new kernel)
            Title Linux 3
            Root (hd0,6) 
            Kernel  /vmlinuz-2.4.25-5.ELAKKI  or  root = LABEL = /
            Initrd   /initrd-2.4.25-5.ELAKKI.img

Now reboot the computer after that your new kernel is ready for work and you can perform any task on this kernel that we can perform on the operating system (Red Hat Enterprise Linux -3)
Notes:  The commands are case sensitive so make sure that you have entered the same command as mention above.

Feedback: Ill appreciate receiving your comments, criticism and feedback at my E-mail id   www.linuxhq.com


Akhilesh Kumar Kamal.

Rate This Article: poor excellent
Comments about this article
rebuild the rhel 5.3 kernel
writen by: aklinux1988 on 2010-07-26 18:41:00
How we can rebuild the kernel if using rhel 5.0 or fedor!!
RE: rebuild the rhel 5.3 kernel written by aklinux1988:

Comment title: * please do not put your response text here