this assumes that you have a PC with a 32-bit Intel type CPU. The procedures for other CPUs vary and are not, as of this writing, covered on the Red Hat exams. The following list of RPMs are associated with the source code:
When you install RHEL 3, you’ve probably already installed most of these packages. Alternatively, it may be faster to install the Kernel Development package group using the Package Management utility. This utility automatically takes care of any dependencies.
Navigate to the /usr/src directory with the cd /usr/src command. Run the ls -l command. You should see a link between the linux-2.4 directory and the location of your source code files. In RHEL, that is by default the /usr/src/linux-2.4.21-4.EL directory.
Navigate to the /usr/src/linux-2.4 directory. You’ll be running the remaining kernel configuration commands from this directory.
Set up a unique name for the kernel that you’re about to modify. Open the Makefile file in a text editor. Look for the EXTRAVERSION variable. Red Hat adds this variable as a suffix to the recompiled kernel. Modify this variable as desired; save and exit from Makefile.
Jot down the value of the EXTRAVERSION variable here: ______________
Determine the correct CPU on your hardware. Use the command
# cat /proc/cpuinfo
Jot down the CPU model name here: ________________
Run the ls /usr/src/linux-2.4/configs command. You’ll see a list of available default kernel configuration files. Find the file associated with your CPU. If your computer has more than one CPU, use the smp version of the kernel, if available. If your computer has more than 4 GB of RAM, use the hugemem version of the kernel, if available. Save it in the /usr/src/linux-2.4 /.config file.
Make sure you’re in the /usr/src/linux-2.4 directory. Clean up any stray source code from previous kernel reconfigurations with the following command:
# make mrproper
Wait until the messages are complete. Problems are rare at this stage.
Next, it is time to configure your kernel, using one of the three major tools:
make config A line-by-line tool that gives you a choice with all kernel options
make menuconfig A text-based menu that allows you to select just the changes you want
make xconfig A GUI interface that works only in the X Window System
Set the processor type to match your hardware (for example, Pentium, Pentium II, Pentium III, Pentium IV).
Return to the kernel configuration tool of your choice. Turn off all unneeded devices. Some possible unneeded devices are in the following categories:
Be sure to turn on Kernel Loadable Modules support.
Save your changes and exit.
When you save the new configuration, the kernel configuration tool overwrites your /usr/src /linux-2.4/.config file.
Resolve all kernel dependencies (between sources) with the following command. This will produce a lot of output and may take several minutes.
# make dep
Prepare the source code directories to create the new kernel with the following command:
# make clean
Once your dependencies are resolved, it’s time to build a new compressed kernel image, with the following command:
# make bzImage
This is the actual kernel build, which will take some time. You may take this opportunity to log into another terminal and run one of the other labs.
The easiest way to see if the kernel build worked is to run the following command immediately after the messages from make bzImage command stop:
# echo $? 0
If you got a 0, everything worked (success). Any other result indicates a failure during the kernel build process. In that case, go back and reconfigure your kernel to make a configuration that works.
Check for the existence of two new files. Run this command:
# ls -l System.map arch/i386/boot/bzImage
It should show you two files, a relatively small System.map and a much larger bzImage.
Make the loadable modules that will be used by this kernel:
# make modules
Install the new custom kernel files into their correct locations and update your boot loader so that it knows about your new kernel. The make install command should perform all of these tasks.
Check to see that the make install command worked. Based on the EXTRAVERSION variable that you set earlier, check your /boot directory. You should see at least a new initrd, System.map, and vmlinuz file in this directory, with this variable as a suffix. Otherwise, you’ll need to copy these files yourself. Also, check your boot loader configuration file (/etc/grub.conf for the default GRUB boot loader).
If the make install command didn’t put an initial RAM disk (initrd) into the /boot directory, you’ll have to create one with the following command (if your version and EXTRAVERSION variables are different, revise this command accordingly):
# mkinitrd /boot/initrd-2.4.21-4.ELcustom1 2.4.21-4.ELcustom1
Congratulations, you have just installed a custom kernel on your new system. As long as you also have your original kernel in your boot loader menu, test it out!
Run the reboot command. You should see both kernels in the boot loader menu. Try your custom kernel!