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!

  3. Also can do as
    5.Compile and install kernel modules
    # make modules
    # make modules_install
    # make install
    Then chmod a+x /boot/vmlinuz-2.6.30

  4. 1. cd /usr/src/kernel
    2. wget “http://www.kernel.org/pub/linux/kernel/v2.6/longterm/v2.6.27/linux-2.6.27.59.tar.bz2”
    3. tar xvfj linux-2.6.27.59.tar.bz2
    4. cd linux-2.6.27.59
    5. make clean && make mrproper
    6. make menuconfig
    7 make clean
    8. make -j 7 bzImage
    9. make -j 7 modules
    10. make -j 7 modules_install
    11. make install


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: