Procedure for Compiling Kernel
Under RedHat 7.2
Overview:
There are
few gotcha's in this so it is best I write them down before
I forget and before I do it again
Do the following:
-
- Download the kernel source
from a kernel.org mirror
- I downloaded 2.4.18
so I will use that as an example
- My old kernel source was
2.4.7-10 so any reference to that is to be considered the
previous kernel on your system
-
- cp the linux-2.4.18.tar.gz
to the /usr/src dir and unzip/tar it
- Before you untar the new
kernel source make sure that you delete any soft links that may point to
/usr/src/linux--> /usr/src/linux2.4.7-10 or you will overwrite your old
source
- It is a very good idea
to backup your old source by running #tar -zcvf linux2.4.7-10.backup-<date>.tar.gz
linux2.4.7-10 in the /usr/src dir
- tar zxvf linux-2.4.18.tar.gz
-
- Either copy an old config
file from a known kernel or just run make xconfig to make a fresh one
- It is a good idea to copy
the kernel .config files from each kernel build to /boot/config-<kernel-date>
- It can be a little difficult
to know what you need to include in a kernel so a previous kernel build .config
file can be very helpful just exclude all the stuff that you know you really
wont need
-
- Once you have created
the .config file run make dep from the /usr/src/linux dir
-
- Run make clean
- This next bit is important dont skip
it. Open the Makefile in /usr/src/linux and add your own special bit of EXTRAVERSION
code to identify your kernel
- I use -yyyy-mm-dd or the extra
feature I have added like -ntfs
-
- Next bit is Compile Time
- Run make bzImage
- Run make modules
-
- Now it's Install Time
- Run make modules_install
- If your running scsi then
you need a initrd
- /sbin/mkinitrd /boot/initrd-2.4.18-2002-04-01.img
2.4.18-2002-04-01
- Run make install
to copy your kernel and stuff to /boot etc
-
- OK it's time to edit the
boot loader
- This is what you should
see I am just going to include a copy of my grub file
# 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,2)
# kernel /boot/vmlinuz-version
ro root=/dev/hda3
# initrd /boot/initrd-version.img
#boot=/dev/hda
default=3 <-- Incidently this is arrived at by counting from 0 from the
first title to the number of the kernel/OS you wont to load automatically
at boot.
timeout=10
splashimage=(hd0,2)/boot/grub/splash.xpm.gz
title Red Hat Linux (2.4.7-10)
root (hd0,2)
kernel /boot/vmlinuz-2.4.7-10 ro root=/dev/hda3 hdc=ide-scsi
initrd /boot/initrd-2.4.7-10.img
title xp
rootnoverify (hd0,0)
chainloader +1
title Red Hat Linux (2.4.7-10ntfs)
root (hd0,2)
kernel /boot/vmlinuz-2.4.7-10ntfs ro root=/dev/hda3 hdc=ide-scsi
initrd /boot/initrd-2.4.7-10ntfs.img
title Red Hat Linux (2.4.18-2002-04-01)
root (hd0,2)
kernel /boot/vmlinuz-2.4.18-2002-04-01 ro root=/dev/hda3
hdc=ide-scsi
initrd /boot/initrd-2.4.18-2002-04-01.img
-
- OK you're done and don't
blame me if it doesn't work
James McDonald - Mon Apr
1 09:31:03 EST 2002