-->
Page 57
As each new version of the source tree is released, a corresponding patch also is released containing the differences between the two versions. The patch, as you can imagine, is much smaller than the entire new source tree, thereby making it a much quicker upgrade.
When you're patching the Linux kernel, keep in mind that patches apply to only one particular version of the Linux kernel. For example, if you have the 2.0.27 kernel, the only patch that will apply to it is for the 2.0.28 kernel. If you want to bring your kernel up to version 2.0.30, you will need to apply three patches: 2.0.28, 2.0.29, and 2.0.30. The patch files are available in the same directories as the kernel sources at the FTP and Web sites mentioned previously in this chapter.
After you download a patch, you need to use a combination of the tar and patch programs to make the changes. Begin by moving the patch into the /usr/src directory. After it is there, run the commands
cd /usr/src gzip -cd patch-XX.gz | patch -p0
where XX is the version number of the patch you are applying. For example, you would apply the following to the 2.0.29 kernel:
cd /usr/src gzip -cd patch-2.0.30.gz | patch -p0
After you apply the patch, check for any files ending in .rej in the /usr/src/linux directory. If you find such files there, verify that you applied the patch correctly. If you are sure you patched correctly, watch for an update patch within a day or two. If an error occurs with the patch file, a new version of the patch will appear.
Modules are chunks of the kernel that are not permanently loaded into memory at boot time. Instead, they are loaded on demand and after a period of non-use are removed from memory. Modules are commonly used for networking code on a machine that is not permanently connected, supporting devices not often used, and so on. Although you can make even commonly used kernel code a module, you might find that the overhead in reloading it often outweighs the benefits of it being removed from memory when not in use.
The Linux kernel as of version 2.0 has easy-to-use support for modules. Modules have, for all practical purposes, become transparent in their operation. If you are curious about the details of their operation, read the documentation that comes with the insmod, rmmod, ksyms, and lsmod programs.
Page 58
Now that you have the kernel source tree unpacked and ready to go in /usr/src/linux, you can begin the configuration.
WARNING |
Before making any key changes to a system, such as installing a new kernel, you should have a boot disk ready. In the unfortunate event that you misconfigure something (and everybody does eventually), you will need a way to get back into your system. |
You can configure the Linux kernel in one of three ways. The first (and original) method is to use the make config command. It provides you with a text-based interface for answering all the configuration options. You are prompted for all the options you need to set up your kernel.
The text-based interface is a good backup for instances in which you don't have fancy screen control (for example, your console is an old terminal for which you don't have a termcap setting); hence, you should be familiar with it.
More likely, however, you will have a standard PC console. If so, you can use the make menuconfig command, which provides all the kernel options in an easy-to-use menu. For the sample configuration in this chapter, you will use the make xconfig command, which provides a full graphical interface to all the kernel options.
For the sample configuration, assume that the system is a generic Pentium class PC with an EIDE hard drive, IDE CD-ROM, an Adaptec 2940 SCSI card, and a 3Com 3C905 Ethernet card. The system is being configured as a server, so use a stock 2.0.30 kernel. (Remember: Never use development kernels on production systems!)
To start the configuration tool, change into the directory /usr/src/linux and invoke the following command:
make xconfig
After a brief pause (some text will scroll down your screen), a window like the one shown in Figure 5.1 appears.
Page 59
The menu options, which are centered in the middle of the window, start with Code maturity level options and end with Kernel hacking. By using the four buttons below the menu, you can load or save configurations to disk for further work.
Under each top-level menu in this opening window is a list of options that you can tag to either compile into the kernel, compile as a module, or not include at all. Remember that each option that you elect to compile into the kernel makes the kernel a little larger, thereby requiring more memory. Therefore, include only what you need, but be sure to include key system functions into the kernel such as network drivers and filesystem support for your boot drive. Essentially, you should add any feature you will need on a constant basis. Features that are not often used, such as PPP support, are best compiled as modules.
To start, take a close look at the menu under Code maturity level options. Begin by clicking that menu. This action brings up the Code maturity level options window, as shown in Fig-ure 5.2.