Compiling a linux 2.4 kernel.
The currently running kernel is 2.4.20-8 and re-compiling it makes 2.4.20-8custom. The steps are:
Step 1: make xconfig
Step 2: make dep (because it was instructed)
Step 3: make bzImage (bzImage is same as vmlinuz, it's renamed to vmlinuz)
Step 4: make modules
Step 5: make modules_install (This creates directory /lib/modules/2.4.20-8custom. This directory contains a 'build' directory that is a symbolic link to /usr/src/linux. The same case is with /lib/modules/2.4.20-8/build.
It is necessary to do make modules_install because probably the currently running kernel looks for the modules in /lib/modules/_version_current_kernel/.
So, if you run the new kernel (2.4.20-8) without running 'make modules_install', the new kernel will not find /lib/modules/2.4.20-8custom, and hence will not be able to find the modules and hence will not boot up properly (it may not boot up at all).
BUT I HAVE HACKED IT BY CHANGING THE "EXTRAVERIONS" VARIABLE IN THE TOP LEVEL MAKEFILE (FROM -8custom to -8) SO THAT THE VERSION OF THE NEWLY COMPILED WOULD STILL BE THE SAME (2.4.20-8), AND I WAS BE ABLE TO BOOT UP THE NEW KERNEL. BUT THERE WAS GLITCH, I COULDN'T BUILD "INITRD" AND HENCE I COMPILED 'EXT3' FILESYSTEM IN THE KERNEL RATHER THAN AS A MODULE. THE KERNEL BOOTED UP FINE AFTER THAT.
The directories /lib/modules/2.4.20-8 and /lib/modules/2.4.20-8custom look almost the same.
Step 6: make install (No need of doing this if you have already made bzImage. It makes vmlinux again (already made in 'make bzImage'). Then ultimately it runs the 'install.sh' script in /usr/src/linux/arc/i386/boot directory.
This script basically copies bzImage (renamed to vmlinuz-XXX), and System.map file from /usr/src/linux directory to the /boot directory. The parameters to this script can be read in the script. One of the parameters is the version of the new kernel.
If '/sbin/installkernel' script is present then it will call that script and 'installkernel' script will do all these tasks. 'installkernel' script will also make the initial ramdisk image (initrd) using the 'mkinitrd' command. This is needed if the 'ext3' filesystem is compiled as a module. If 'ext3' filesystem is built in the kernel, then initrd is not needed. This script also updates the 'grub.conf' file in /boot/grub directory. The mkinitrd would be something like this -
mkinitrd [-f] initrd_image_name current_kernel_version
The initrd image is always named as initrd-$(current_kernel_version).img. Our version is 2.4.20-8custom and hence our initrd image name would be named initrd-2.4.20-8custom.img
Initrd image can be made only if the directory /lib/modules/2.4.20-8custom exists. For any initrd-XXX.img image, the /lib/modules/XXX directory should exist.
For the system to be able to load up the modules successfully, the /lib/modules/XXX directory should be present (The kernel version is also XXX). The modules to be loaded are loaded from this directory. If your sound driver is compiled as a module and if the /lib/modules/XXX directory doesn't exist then the sound driver will not be loaded when you try to play a sound.
You may get an error saying "The driver could not be loaded". I have got this error. The device has been recognized but the driver could not be loaded.
(Alternate) Step 6: In case you don't want to run 'make install' then do the following:
(Alternate) Step 6.1: Move vmlinuz-XXX, initrd-XXX, System.map-XXX, to .old in the /boot directory. Don't overwrite these files. Update grub.conf so that you have an old running kernel (in case your new kernel doesn't boot up).
(Alternate) Step 6.2: cp /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinux-XXX
(Alternate) Step 6.3: cp /usr/src/linux/System.map /boot/System.map-XXX
(Alternate) Step 6.4: Create a symbolic link System.map to System.map-XXX in the /boot directory.
(Alternate) Step 6.5: Make initrd in /boot directory:
mkinitrd initrd-XXX.img XXX
(Alternate) Step 6.6: Update /boot/grub/grub.conf accordingly
(Alternate) Step 6.7: In case initrd is not used, you have to build ext3 in the kernel and the kernel 'root' parameter variable in grub.conf would be the actual device name. (root=/dev/hdaX).