A blog for Linux Lovers.

Posted by sibu on March 8, 2009

Kernel Compilation

Kernel Compilation

cd /usr/src/linux

Install your kernel source from RPM
$ rpm -i filename.rpm

or download the kernel source from

Go to your /usr/src/linux directory
$ cd /usr/src/linux

Applying the Patch

For the purpose of this guide, we will use linux-2.2.x for the kernel name. You should replace the x with the version number of the patch you are installing.

1. Move the downloaded kernel patch to the /usr/src/linux directory.

2. cd /usr/src/linux

3. If you downloaded a patch with a .gz extension, execute the following command:
gunzip patch-2.2.x.gz

If you downloaded a patch with a .bz2 extension, execute the following command:
bunzip2 patch-2.2.x.bz2

4. There should now be a file called patch-2.2.14 in the /usr/src/linux directory. Apply the patch to the kernel source tree with the following command:
patch -p1 < patch-2.2.x or
zcat patch-2.2.x.gz | patch -p1

Run configuration program

There are 3 to choose from:

config -> text only
xconfig -> graphical (must be running X)
menuconfig -> text baised, menu driven

Output will be saved as .config

The following commands will compile and install the new kernel.

make dep - This step identifies kernel dependencies so that they will be resolved at compile time.

make clean - This step removes any old object files from previous builds. Even if you haven’t compiled a kernel before, this step only takes a second and doesn’t do any damage.

make bzimage - This step actually compiles the kernel. This results in the kernel being named bzImage and will be located in the /usr/src/linux directory. This step will take some time to complete..

make modules - This step compiles all the modules that the kernel may need to use in the future, such as the network and sound card drivers. This step will take some time to finish.

make modules_install - This step moves the module object files into the correct directory.

make install - This step will move the new kernel and its associated files into the correct directories on your system.

Add A Comment