| :: [linux] Compiling the Red Hat Linux kernel. :: | ||||
| HOME |
|
I have take this information from RedHatSite
and a HOWTO on TLDP site.
I have put my own comments below,
so that it will help every new comer to
compile a RH 9.0 kernel to suite his own needs.
1. The Redhat 9.0 system comes with a
2.4.20 kernel. Most of the defaukt redhat, also installs the kernel
source.
You can find out which kernel you are
running using the command
#>uname -r
2. To check if the kernel source
(and source version)is installed on your system or not type
#>rpm -qi
kernel-source.
Name :
kernel-source
Relocations: (not relocateable)
Version : 2.4.20 Vendor: Red Hat, Inc. Release : 9 Build Date: Wed Apr 2 12:42:58 2003 Install Date: Tue Apr 29 12:17:53 2003 Build Host: porky.devel.redhat.com Group : Development/System Source RPM: kernel-2.4.20-9.src.rpm Size : 169410724 License: GPL Signature : DSA/SHA1, Mon Apr 7 10:11:18 2003, Key ID 219180cddb42a60e Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> Summary : The source code for the Linux kernel. Description : The kernel-source package contains the source code files for the Linux kernel. These source files are needed to build custom/third party device drivers. The source files can also be used to build a custom kernel that is better tuned to your particular hardware, if you are so inclined (and you know what you're doing). 3. In RedHat the kernel source is installed
in /usr/src/linux-kernelversion. In our case it is
/usr/src/linux-2.4.20-9. However a link
/usr/src/linux-2.4 is also created in the same directory that
points to the current kernel
source.
4. The current running kernel and the
kernel source are two different things.. So don't worry that your system
will
come down if you do something wrong. Just
go ahead and do the following and u should be pretty safe.
5. It is important that u make a boot
diskette. This can be done using the command.
#>/sbin/mkbootdisk `uname -r`
6. Now go the kernel directory and do make
mrproper as below: BUT NOTE: make mrproper will remove any previous
configurations u might have done. All such configurations are placed in the
/usr/src/linux2.4/.config file. If there is no such file (and most probably there wont be), u don't have to
worry, but if you would like to continue with previous configuration
just save the .config to .config.save and
later copy it.
REDhat also provides some example configs
in /usr/src/linux2.4/configs/. You can check what configuration is used
for your current kernel by checking
/boot/.. My /boot directory shows config-2.4.20-9. So i guess i can copy this
file to
my /usr/src/linux2.4/.config and i will
have the same configuration as my current running kernel.
here are the commands.
#>cd
/usr/src/linux-2.4
/usr/src/linux-2.4 #>make
clean
/usr/src/linux-2.4 #>make
mrproper
/usr/src/linux-2.4 #>cp
configs/kernel-2.4.20-i586.config .config
OR
/usr/src/linux-2.4 #>cp
/boot/config-2.4.20-9 .config
OR
/usr/src/linux-2.4 #>cp
config.save .config
OR
DON"T DO ANYTHING IF YOU WANT
TO HAVE A FRESH CONFIGURATION
7. Now to start the configuration
use
/usr/src/linux-2.4 #> make
xconfig (If you are in X environment)
OR
/usr/src/linux-2.4 #>
make menuconfig (if you are on console)
You can now select the kernel configuration u
want. You should already know what Modules are and make maximum use of
it.
8. Now use Make
dep
/usr/src/linux-2.4 #>
make dep 9. Now comes the interesting part. You
should give a customized name to your kernel. Just edit the makefile and
change
the EXTRAVERSION parameter. I have shown my
Makefile (just the top lines) below:
/usr/src/linux-2.4 #> cat
Makefile | more
VERSION = 2
PATCHLEVEL = 4 SUBLEVEL = 20 EXTRAVERSION = -9custom by defualt the Redhat people name the new kernel as 2.4.20-9custom. I like
to call it something else. So i replace the
"custom" by my initials "sk1" as show below
VERSION = 2 PATCHLEVEL = 4 SUBLEVEL = 20 EXTRAVERSION = -9sk1 10. Now make the
bzimage.
/usr/src/linux-2.4 #> make
bzImage
11. Build all the modules using (This is
taking a hell lot of time on my machine).
/usr/src/linux-2.4 #> make
modules 12. install the modules with make
modules_install. Note that all the modules will be installed in
/lib/modules/2.4.20-9sk1. Just check this directory to see
that this is done.
/usr/src/linux-2.4 #> make
modules_install
/usr/src/linux-2.4 #> ls
/lib/modules/2.4.20-9sk1
13. Use make install to copy the new kernel
and its associated files to its proper place. Some people might tell you
that "Such is not recommended". But I think
it does not matter. "make install" will copy
"usr/src/linux-2.4/arch/i386/boot/bzImage"
which is the kernel to /boot/vmlinuz-2.4.20-9sk1.
It also changes the existing "vmlinuz" link
to point to /boot/vmlinuz-2.4.20-9sk1.
it also creates "initrd-2.4.20-9sk1.img"
which is usefull is you have SCSI drives. check if this is there.. if
this
file is not there, just create it manually
using the command
/usr/src/linux-2.4 #> make
install
CHECK THE /boot directory to see if there is an
initrd-2.4.20-9sk1.img file. If it is not there use
#>/sbin/mkinitrd /boot/initrd-2.4.20-9sk1.img
2.4.20-9sk1 it also chnages the grub boot loader.. An example grub loader, before modification is shown below ******************************************************************************* # grub.conf generated by anaconda ******************************************************************************* and here is the same grub.conf after modification *******************************************************************************# grub.conf generated by anaconda 14. Now reboot the system and see if your kernel is there or not. 15. Mine worked very well. Even
if you select the new kernel and it does not work,
just let it remain in the
system (assuming you have enough space). Else you
might just have to modify the
/boot directory a bit. I will wrote about this
when i face it.
Now when you need to make a new
kernel, just change the EXTRAVERSION and follow all the steps.
|