Tuesday, November 12, 2013

How to compile kernel from source rpm

Step1:
Get the kernel source rpm( like kernel-2.6.32-358.el6.src.rpm) from kernel ISO image or download it from net

Step2:
Extract the source rpm using below command

rpm2cpio kernel-2.6.32-358.el6.src.rpm | cpio -id

Step3:
Extraction of src rpm provides the linux source tar ball (like linux-2.6.32-358.el6.tar.bz2).
Untar the source using below command.

tar -xjvf linux-2.6.32-358.el6.tar.bz2

Step 4:
go to the untarred directory (cd linux-2.6.32-358.el6)
and enter make menuconfig
and select the required configuration and save it.

Step 5:
Open the Makefile and edit the string “EXTRAVERSION = " (like “EXTRAVERSION = -xyz) for custom kernel string name
Compile the kernel using below command.

make

Step 6:
Compile the kernel modules
make modules

Step7:
Install the compiled modules
make modules_install

Step8:
Install the kernel
make install

Reboot the system into custom kernel now.