Posted by: kezhong | July 19, 2009

Building a New Kernel

Linux is probably the only operating system that has a new kernel every so often. The most common reason to upgrade a kernel is to take advantage of some newer device drivers to handle some specific devices or you need to upgrade due to a bug in the kernel.

The release of my Fedora system was 2.6.29.4. I checked it through the following command.
# uname –r
2.6.29.4-167.fc11.i686.PAE 

Then I upgraded it to 2.6.30 as below steps. 

1.Download source from kernel.org
# cd /usr/src
# wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.tar.bz2 

2.Unpack the source file
#tar xvjf linux-2.6.30.tar.bz2 

3.Create configuration file
Firstly, I installed the “kernel-devel”, “kernel-headers”, and “gcc” packages.
# yum install kernel-devel kernel-headers gcc -y
# cd linux-2.6.30
# cp /usr/src/kernels/2.6.29.5-191.fc11.i586/.config .
# make oldconfig 

4.Compile kernel and copy the new kernel to the /boot directory
# make dep
# make clean
# make bzImage
# cp arch/x86/boot/bzImage /boot/vmlinuz-2.6.30
# chmod a+x /boot/vmlinuz-2.6.30
# cp System.map /boot/System.map-2.6.30 

5.Compile and install kernel modules
# make modules
# make modules_install 

6.Create a new initial ramdisk
# mkinitrd /boot/initrd-2.6.30.img 2.6.30
Note: The format of the mkinitrd command: mkinitrd <image file> <kernel version> 

7.Update GRUB
Edit the /boot/grub/menu.list file, add the following lines into it.
# vi /boot/grub/menu.list
title Fedora (2.6.30)
            root (hd0,0)
            kernel /vmlinuz-2.6.30 ro root=/dev/mapper/VolGroup-lv_root rhgb quiet
            initrd /initrd-2.6.30.img 

8.Reboot and verify

Reference
SYA710 Building a New Kernel


Responses

  1. Nice post Steven !!!

  2. cool.. there is online kernal patch available too.. go try it, and let me know how stable it is, hehe..

    • what an indolent guy! hehe!


Leave a response

Your response:

Categories