Building a new kernel

For most situations, you don't need to be building new kernels. But in case you want to, this section is here to help speed up the process.

This section discusses:


Where to get the kernel source

When you install Linux, you can specify that you want the kernel source installed. Or you can add the kernel source later from either the Red Hat 9 CD or
from rpmfind.

Many people recommend downloading latest stable version of Linux kernel sources, rather than using the version shipping with Red Hat, since newer kernels support more hardware, etc. To download the latest version see The Linux Kernel Archives at http://www.kernel.org. The latest stable version is listed first. Then download the kernel source archive by clicking on the F (which stands for Full source):

linux kernel source download

Then uncompress and extract the kernel source into /usr/src on your system:

cd /usr/src
bzcat linux-2.4.20.tar.bz2 | tar xvf -
Then create a symbolic link:
ln -s linux-2.4.20 linux

How to build a kernel

If this is the first time you're building a kernel on a Red Hat system, it's easiest if you start with Red Hat's kernel sources and with the kernel configuration template that your system was built with:
# cd /boot
# ls config*
config-2.4.20-8
# cp config-2.4.20-8 /usr/src/linux/.config
Then you can customize your kernel configuration by typing:
cd /usr/src/linux
make xconfig
After you are finished customizing the kernel, you can build it:
make dep bzImage modules modules_install

What to do after you build a kernel

Copy the resulting kernel to the /boot directory with any name you'd like for it:
cp /usr/src/linux/arch/i386/boot/bzImage /boot/mynewkernel
If your machine is configured to boot with
lilo then edit /etc/lilo.conf, and add a reference to your new kernel. Look at other entries in /etc/lilo.conf to determine what disk shoud be used, etc. Here is a sample of what one might add to /etc/lilo.conf:
image=/boot/mynewkernel
        label=mynewlabel
        read-only
        root=/dev/hda8
Then type:
lilo
If your machine is configured to boot with grub then modify /boot/grub/menu.lst file. Here is an example of what you might add to the /boot/grub/menu.lst file:
title Linux 2.4.20 with all my new configuration
    root (hd0,1)
    kernel /boot/mynewkernel root=/dev/hda2
That is all (you don't need to run a command after modifying the grub configuration file like you would using LILO).

When you reboot your machine, you will be able to choose to boot the new kernel.


Where to get more information

Linux Quick Reference Home
Linux Migration Home