Tuesday, 25 January 2011

How to compile a kernel from kernel.org in Fedora 14

This quick guide will show you how to compile and install a kernel from kernel.org in Fedora 14.

Start


Open a terminal and work through the below list of commands. Modify where appropriate.


Install the following packages

su -c 'yum install rpmdevtools yum-utils gcc make ncurses-devel'

Setup your build environment

rpmdev-setuptree

Download and extract your Kernel source

cd ~/rpmbuild/SOURCES

wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.37.tar.gz

tar -xf linux-2.6.37.tar.gz

Configure and Compile it

cd linux-2.6.37

make menuconfig

export CONCURRENCY_LEVEL=3

time make rpm

General rule for concurrency level = number of processor cores + 1


Install it

cd ~/rpmbuild/RPMS/x86_64

su -c 'rpm -ivh --force kernel-2.6.37-1.x86_64.rpm'

cd /boot

su -c 'mkinitrd initramfs-2.6.37.img 2.6.37'

su -c 'vi grub/grub.conf'

Fedora 32-bit users replace x86_64 with i386

Edit your grub.conf file and add an entry for your new kernel. Just copy your first kernel entry and modify it.

Note: Please do not copy this grub.conf, it is for illustrative purposes only.

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,0)
#          kernel /boot/vmlinuz-version ro root=/dev/sda1
#          initrd /boot/initrd-[generic-]version.img
#boot=/dev/sda1
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu

title Fedora (2.6.37)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.37 ro root=UUID=162b11c2-d9a1-4487-86d5-6ade5c5ee055 rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=uk rhgb quiet
        initrd /boot/initramfs-2.6.37.img

title Fedora (2.6.35.10-74.fc14.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.35.10-74.fc14.x86_64 ro root=UUID=162b11c2-d9a1-4487-86d5-6ade5c5ee055 rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=uk rhgb quiet
        initrd /boot/initramfs-2.6.35.10-74.fc14.x86_64.img

title Fedora (2.6.35.6-45.fc14.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.35.6-45.fc14.x86_64 ro root=UUID=162b11c2-d9a1-4487-86d5-6ade5c5ee055 rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=uk rhgb quiet
        initrd /boot/initramfs-2.6.35.6-45.fc14.x86_64.img

title Other
        rootnoverify (hd0,4)
        chainloader +1

Boot from your new kernel


Restart your system and enjoy your new kernel.