introductioninstalling redhatunix commandsediting filesssh
sitemapapacheftptcp/ipmisc-notesresources

redhat 7.2: how to customize the redhat kernel

The following guide shows how to compile and install a custom kernel under RedHat Linux. The instructions below have been tested using RedHat 7.2. I highly recommend that you perform the proceedure on a test machine before implementing a custom kernel on a production server as it is pretty easy to make a kernel that doesn't work properly. At least that is the case for me. By compiling a custom kernel, you can turn on/off options that exist in the kernel like NTFS filesystem support or Firewire as examples. Be warned it can take a pretty long time to do. I performed the below steps on a PII 400 and it took a few hours.

installing the kernel sources.

Check to see if you already have the kernel source installed with:

$ rpm -q kernel-source
kernel-source-2.4.9-13

If the kernel source is not installed, download them from your favorite RedHat mirror site. You will need to be logged in as root to install the kernel source. Install the kernel source with:

rpm -ivh kernel-source-2.4.9-13.i386.rpm

re-compiling the redhat kernel

Login as the root user.

Change to the /usr/src/linux-2.4.9-13 directory
# cd /usr/src/linux-2.4.9-13

"make mrproper"
# make mrproper

"make xconfig"
# make xconfig

Load the default RedHat kernel config for your architecture.
Click "Load Configuration from file"

You can look in /usr/src/linux-2.4.9-13/configs to see what the default kernel configs RedHat uses to compile thier kernels. Choose the correct one for your architecture.

[root@garfield configs]# ls -l
total 408
-rw-r--r-- 1 root root 35981 Oct 30 16:02 kernel-2.4.9-athlon.config
-rw-r--r-- 1 root root 36009 Oct 30 16:02 kernel-2.4.9-athlon-smp.config
-rw-r--r-- 1 root root 45135 Oct 30 16:02 kernel-2.4.9-i386-BOOT.config
-rw-r--r-- 1 root root 36138 Oct 30 16:02 kernel-2.4.9-i386.config
-rw-r--r-- 1 root root 36078 Oct 30 16:02 kernel-2.4.9-i386-smp.config
-rw-r--r-- 1 root root 36108 Oct 30 16:02 kernel-2.4.9-i586.config
-rw-r--r-- 1 root root 36048 Oct 30 16:02 kernel-2.4.9-i586-smp.config
-rw-r--r-- 1 root root 36097 Oct 30 16:02 kernel-2.4.9-i686.config
-rw-r--r-- 1 root root 36565 Oct 30 16:02 kernel-2.4.9-i686-debug.config
-rw-r--r-- 1 root root 36136 Oct 30 16:02 kernel-2.4.9-i686-enterprise.co
-rw-r--r-- 1 root root 36081 Oct 30 16:02 kernel-2.4.9-i686-smp.config

In the dialog box type the full path to the config file you want to use.
Example: /usr/src/linux-2.4.9-13/configs/kernel-2.4.9-i686.config

Click "Ok" to load the config and exit the dialog box.

Click on an option box and put a check in the option that you wish to enable.

Click "m" to build the options support as a module (recommended) or "Y" to build
support directly into the kernel.

Click "Main Menu"

Make any other changes to the kernel config you wish to make then
Click "Save & Exit"

An informational dialog box will popup telling you to run "make dep"
Click "Ok"

"make dep"
# make dep

"make clean"
# make clean

Compile the kernel. "make bzImage"
# make bzImage

Compile the modules "make modules"
# make modules

Install the new kernel modules.
These will be created in /lib/modules/kernel-2.4.9-13custom
"make modules_install"
# make modules_install

Copy the new kernel image to /boot
#cp arch/i386/boot/bzImage /boot/vmlinuz-2.4.9-13custom

Copy the new System.map to /boot
#cp System.map /boot/System.map-2.4.9.13custom

If necessary create a ram disk image for the new kernel. To find out if you need a ram disk look in your /etc/grub.conf or /etc/lilo.conf If you see a line similiar to these then you need to create an image for your new kernel.

From /etc/grub.conf
initrd /initrd-2.4.9-13.img

From /etc/lilo.conf
image = /boot/initrd-2.4.9-13.img

Create a ram disk image
# mkinitrd /boot/initrd-2.4.9-13custom.img 2.4.9-13custom

Edit your /etc/grub.conf or /etc/lilo.conf

Example /etc/grub.conf

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/hda5
# initrd /initrd-version.img
#boot=/dev/hda
default=2
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
password --md5 xxxxxxxxxxxxxxxxxxxxxx
title Red Hat Linux (2.4.9-13)
root (hd0,0)
kernel /vmlinuz-2.4.9-13 ro root=/dev/hda5 vga=791
initrd /initrd-2.4.9-13.img
title Red Hat Linux (2.4.9-13custom)
root (hd0,0)
kernel /vmlinuz-2.4.9-13custom ro root=/dev/hda5 vga=791
initrd /initrd-2.4.19-13custom.img
title windoze
rootnoverify (hd0,3)
chainloader +1
#end grub.conf

With grub all you have to do is add the entry for your new kernel and you are ready to reboot your system.

Example /etc/lilo.conf

# lilo.conf
prompt
timeout=50
default=linux
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
message=/boot/message
vga=791
lba32

image=/boot/vmlinuz-2.4.9-13
label=linux
initrd=/boot/initrd-2.4.7-13.img
read-only
root=/dev/hda5

image=/boot/vmlinuz-2.4.9-13custom
label=linuxcustom
initrd=/boot/initrd-2.4.7-13custom.img
read-only
root=/dev/hda5

other=/dev/hda4
optional
label=windoze
# end lilo.conf

After adding your new entry to /etc/lilo.conf. You must rerun lilo.
# lilo -v

<will soon have a sample lilo -v output here>

Look for any errors. If you don't see any your are ready to reboot your system.