Download your favorite Linux distribution at LQ ISO.
Go Back > Linux Answers > Applications / GUI / Multimedia
User Name


By mchirico at 2004-03-24 14:34
How to Compile 2.6 kernel for RedHat 9/8
Mike Chirico
Last Updated: Wed Mar 24 09:12:06 EST 2004

The latest version of this document can be found at:

For configs ref:


Download the latest version of the kernel and any patches.
This documentation is done with linux-2.6.3, but look for
later versions.

Also take a look at This has
some useful hints on some of the changes needed.


Download the latest version of module-init-tools
"module-init-tools-3.0.tar.gz" and


Install module-init-tools. This will replace depmod
[/sbin/depmod] and other tools.

tar -zxvf module-init-tools-3.0.tar.gz
cd module-init-tools-3.0
./configure --prefix=/sbin
make install
./generate-modprobe.conf /etc/modprobe.conf


Install modutils-2.4.21-23.src.rpm. You may get warnings
about user rusty and group rusty not existing. Also, yes,
you'll have to force the install. If you don't do these steps
for both Redhat 9 and Redhat 8, you'll have problems with the
make modules_install.

rpm -i modutils-2.4.21-23.src.rpm
rpmbuild -bb /usr/src/redhat/SPECS/modutils.spec
rpm -Fi /usr/src/redhat/RPMS/i386/modutils-2.4.21-23.i386.rpm


Install and configure the kernel. Do NOT use the /usr/src/linux
area! Reference the README. I put my files in /home/src/kernel/

gunzip linux-2.6.3.tar.gz tar -xvf linux-2.6.3.tar cd

If you have patches install these now:

bzip2 -dc ../patch-2.6.xx.bz2 | patch -p1


Copy the appropriate /usr/src/linux-2.4/configs
[kernel-2.4.20-i686.config, kernel-2.4.20-i686-smp.config]
to .config in whatever directory you are installing. In my
case it's /home/src/kernel/linux-2.6.3

cp /usr/src/linux-2.4/configs/kernel-2.4.20-i686.config \

If you don't have the source configs, you can download them
from here:

I've also included a file config2.6-chirico which was a 2.6
version for some of my systems. This isn't a bad reference if
you run into trouble.


Assuming you copied the appropriate kernel-2.4 config to
.config, run the following which will run through necessary
questions for the 2.6 kernel. Or, you might want to use the
config2.6-chirico...this has already been run through make
oldconfig on my system, and I've answered the necessary questions
for a general system.

make oldconfig


This is very important. Make sure you're .config has the
following in it CONFIG_EXT3_FS=y You'll run into the following
error if you leave this =m instead of =y:

pivotroot: pivot_root(/sysroot,/sysroot/initrd) failed

This is because Redhat 9.0 and 8.0 use the ext3 filesystem
for /boot ...


Edit the Makefile and add changes to the Extraversion is needed.
Patches will update these values as well.

EXTRAVERSION = -skim-ch6

STEP 10:

make bzImage

STEP 11:

make modules

STEP 12:

make modules_install

STEP 13:

make install

If you come across errors here, what version of "depmod" is
being picked up in your path?

Also, if you get a module not found, say the following:
No module aic7xxx found for kernel 2.6.x
Then, in /lib/modules/2.6.x/kernel/drivers/scsi/aic7xxx/
cp aic7xxx.ko aic7xxx.o

insmod should look for aic7xxx.ko ;but , it looks for aic7xxx.o

If you still have trouble, make the following change in the
and go back to STEP 10.

You also may want to ref

STEP 14:

mkdir /sys

STEP 15:

/etc/rc.sysinit needs to be modified. Look for the following

action $"Mounting proc filesystem: " mount -n -t proc /proc /proc

and after this line enter the following:

action $"Mounting sysfs filesystem: " mount -t sysfs none /sys

Here's my /etc/rc.sysinit for reference:

Be very careful at this step. Backup the /etc/rc.sysinit file.

Thomer [ ] also added
changes to /etc/fstab. I only had to do STEP 16 below.

STEP 16:

Add the following to /etc/fstab for usb support.

/proc/bus/usb /proc/bus/usb usbdevfs defaults 0 0


Check the following:

a. The new image file should be installed on boot and there
should be sym link to it. My latest kernel is 2.6.3-skim-ch6,
and I got the "-skim-ch6" from the values I put in the Makefile,
so I see the following:

vmlinuz -> vmlinuz-2.6.3-skim-ch6 ->

/boot/grub/grub.conf Should have been automatically
updated from make.

In /boot/grub/grub.conf change "default=0" to boot
with the new kernel. Here's an example of my

# grub.conf generated by anaconda
# Note that you do not have to rerun grub after making
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to
# root (hd0,2)
# kernel /vmlinuz-version ro root=/dev/hda6
# initrd /initrd-version.img
title Red Hat Linux (2.6.3-skim-ch6)
root (hd0,2)
kernel /vmlinuz-2.6.3-skim-ch6 ro root=LABEL=/
initrd /initrd-2.6.3-skim-ch6.img

b. The directory /sys exists

c. You added the mount command for sys in /etc/rc.sysinit

d. CONFIG_EXT3_FS=y was used in the .config

e. Run /sbin/lsmod or cat /proc/modules to make
sure a 2.4 kernel module wasn't forgotten. Also
look at "$cat /proc/iomem"


You're done with the 2.6 build. So learn how to develop
2.6 kernel modules. First, checkout the following article

Then, take a look at the following sample code, which shows how
to create /proc entries for communicating with the kernel and writing
out to any available tty device.



Excellent (series of articles):

Here's my sample program:

Good but dated for 2.4 kernel:

by ziox on Wed, 2004-07-14 18:32
[root@Master linux-2.6.6]# make install
ake[1]: `arch/i386/kernel/asm-offsets.s' is up to date.
CHK include/linux/compile.h
Kernel: arch/i386/boot/bzImage is ready
sh /home/basem/src/kernel/linux-2.6.6/arch/i386/boot/ 2.6.6 arch/i386/boot/bzImage ""

NO module /bin/true found for kernel 2.6.6
mkinitrd failed

make[1]:***[install] Error 1
make:***[install] Error 2

what i'm suppose to do

i already installed

on RedHat ~9

by xbaez on Thu, 2004-07-29 16:46
Thanks for the great tutorial

I followever your tutorial step by step (except for the modutils-2.4.21-22.src.rpm package, which is the only one available from your site

Everything goes fine, except two things:

I have to copy module aic7xxx.ko to module aic7xxx.o, same for sg.ko -> sg.o

When I reboot my machine, I see the followings errors:

Loading aic7xxx.o module
insmod: can't read '/lib/aic7xxx.o'

Loading sg.o module
insmod: can't read '/lib/sg.o'

Initializing USB controller (uhci): FATAL: Module uchi not found
Initializing USB controller (usbcore): FATAL: Module usbcore not found
Initializing USB controller (hid): FATAL: Module hid not found

Mouting USB filesystem
grep: /proc/bus/usb/drivers: No such file or directory:

Initializing USB keyboard: FATAL: Module keybdev not found
Initializing USB mouse: FATAL: Module mousebdev not found

Mounting local filesystems: mount: fs type vfat not supported by kernel

Mount /*proc/bus/usb already mounted or /proc/bus/usb busy

FLushing all current rules and user defined chains: iptables v 1.2.7a: can't initialize iptables table 'filter': iptables who? (do you need insmod?)
Perhaps iptables or your kernel needs to be upgraded

Tons of errors

I followed the tutorial excactly as you mentioned. I will appreciate any response since I've been trying to compile a 2.6.x kernel for a few months now



by haymaker on Thu, 2004-09-30 10:25
this seems very nice, but when itry "make menuconfig" and the like, I always get:
"Missing }."
How can that be. I've had this problem for SOO long now and never found anything usefull on the net yet about it.

by madyogi on Wed, 2009-02-11 03:04
This is a great post.

But still I allow myself to add here a tiny supplement that shows how to use a kernel that doesn't have the 'ext3.ko' module built in. Yes, it is possible. It worked for me with 2.6.15 original kernel source.

First make sure you have the old 'mkinitrd' package, that came with your RH9 distribution installed.
Build the initrd image the same way as you did for previous 2.4 kernels (yes, I know it will be bad).

$ cd /boot
$ mkinitrd initrd-2.6.x.img 2.6.x
// whre 'x' is a minor version of the kernel.

Now we try to fix the image. It is most likely the gzipped archive.
$ mkdir /mnt/image
$ gzip -dc initrd-2.6.x.img > 26.img
$ mount 26.img /mnt/image -o loop

Look at the directory and see what it contains:
$ cd /mnt/image
$ ls
// looks sweet

Now see what subdir 'lib' contains. It is most likely empty... :/
$ ls lib
// was it?
If so, copy the necessary modules from /lib/modules subdirectory
$ cp /lib/modules/2.6.15/kernel/fs/ext3/jbd.ko ./lib/
$ cp /lib/modules/2.6.15/kernel/fs/ext3/ext3.ko ./lib/

Now replace the old 'insmod' binary, that resided in ./bin or ./sbin subdirectories with the one that is shipped with 'module-init-tools' package.
$ cp /sbin/insmod.static ./sbin/insmod
$ vi linuxrc

Now in the top of the file, before anything else, add the insmod command that inserts both modules to the kernel.
$ insmod /lib/jbd.ko
$ insmod /lib/ext3.ko

Go back to the boot directory and replace the 'initrd' image.
$ cd /boot
$ umount 26.img
$ gzip -c9 26.img > initrd-2.6.15.img

Thats it. Depending on if you're using LILO or GRUB make necessary configuration changes like simply editing 'lilo.conf' or 'grub.conf' and perform a reboot. If everything went fine, the kernel should boot without any problems. Yes, it worked for me...

P.S. If at the boot time you see some QM_MODULES not implemented and you kernel panics then boot back with 2.4 and replace the 'insmod' binary within the initrd image, you have created. Most likely, you've added an old insmod from 'modutils' package and not the one that comes with 'module-init-tools'.


All times are GMT -5. The time now is 11:28 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration