-->
Previous Table of Contents Next


Chapter 57
Working with the Kernel

by Kamran Husain and Tim Parker

In This Chapter
•   Upgrading and installing new kernel software
•   Compiling the kernel from source code
•   Adding drivers to the kernel
•   Upgrading libraries
•   The Linux C compiler

Usually you will want to leave the Linux kernel alone except when performing a major upgrade, installing a new networking component (such as NFS or NIS), or installing a new device driver that has special kernel requirements. The details of the process used to install the kernel drivers are usually supplied with the software. Since this isn’t always the case, though, this chapter gives you a good idea of the general process for working with the kernel.


Note:  
First a clear warning: don’t modify the kernel without knowing what you are doing. If you damage the source code or configuration information, your kernel may be unusable and in the worst cases, your file system may be affected. Take care and follow instructions carefully. There is a lot to know about kernel manipulation and we can only look at the basics in this chapter.

There are several versions of Linux in common use, with a few inconsistencies between them. For that reason, the exact instructions supplied below may not work with your version of Linux. However, the general approach is the same, and only the directory or utility names may be different. Most versions of Linux have documentation supplied that lists the recompilation process and the locations of the source code and compiled programs.


Note:  
Before doing anything with the kernel or utilities, make sure you have a good set of emergency boot disks, and preferably, a complete backup on tape or disk. Although the process of modifying the kernel is not difficult, it does cause problems every now and again that can leave you stranded without a working system. Boot disks are the best way to recover, so make at least one extra set.

Since the kernel is compiled with the C compiler supplied as part of Linux, we’ll spend the latter part of this chapter looking at the C compiler, its flags, and how you can use it to your advantage. This isn’t meant to be a complete reference to the C system, of course, but should be useful for some basic manipulations you may require when modifying the kernel (or any other source code compiled by C).

Upgrading and Installing New Kernel Software

Linux is a dynamic operating system. There are new releases of the kernel, or parts of the operating system that can be linked into the kernel, which are periodically made available to users. Whether you want to upgrade to the new releases is up to you and usually depends on the features or bug fixes that the new release offers. You will probably have to relink the kernel when new software is added, unless it is loaded as a utility or device driver.

You should avoid upgrading your system with every new release, however, for a couple of reasons. The most common problem with constant upgrades is that you may be stuck with a new software package that causes backward compatibility problems with your existing system or has a major problem with it that was not patched before the new software was released. This can cause you no end of trouble. Most new releases of software wipe out existing configuration information, so you have to reconfigure the packages that are being installed from scratch.

Also, the frequency with which new releases are made available is so high that you can spend more time simply loading and recompiling kernels and utilities than actually using the system. This becomes tiresome after a while. Since most major releases of the Linux operating system are available, the number of changes to the system are usually quite small, so you should read the release notes carefully to ensure that the release is worth the installation time and trouble

The best advice is to upgrade only once or twice a year, and only when there is a new feature or enhancement to your system that will make a significant difference to the way you use Linux. It’s tempting to always have the latest and newest version of the operating system, but there is a lot to be said for having a stable, functioning operating system, too.

If you do upgrade to a new release, bear in mind that you don’t have to upgrade everything. The last few Linux releases have changed only about 5 percent of the operating system with each new major package upgrade. Instead of replacing the entire system, just install those parts that will have a definite effect, such as the kernel, compilers and their libraries, and frequently used utilities. This saves time and reconfiguration.


Previous Table of Contents Next