- Table of Contents
- Copyright
- About the Lead Authors
- About the Contributing Authors
- Acknowledgments
- Tell Us What You Think!
- Introduction
- I. Red Hat Linux Installation and User Services
- Chapter 1. Introduction to Red Hat Linux
- Chapter 2. Installation of Your Red Hat System
- Chapter 3. LILO and Other Boot Managers
- Chapter 4. Configuring the X Window System, Version 11
- Chapter 5. Window Managers
- Chapter 6. Connecting to the Internet
- Chapter 7. IRC, ICQ, and Chat Clients
- Chapter 8. Using Multimedia and Graphics Clients
- II. Configuring Services
- Chapter 9. System Startup and Shutdown
- Chapter 10. SMTP and Protocols
- Chapter 11. FTP
- Chapter 12. Apache Server
- Chapter 13. Internet News
- Chapter 14. Domain Name Service and Dynamic Host Configuration Protocol
- Chapter 15. NIS: Network Information Service
- Chapter 16. NFS: Network Filesystem
- Chapter 17. Samba
- III. System Administration and Management
- Chapter 18. Linux Filesystems, Disks, and Other Devices
- Chapter 19. Printing with Linux
- Chapter 20. TCP/IP Network Management
- Chapter 21. Linux System Administration
- Chapter 22. Backup and Restore
- Chapter 23. System Security
- IV. Red Hat Development and Productivity
- Chapter 24. Linux C/C++ Programming Tools
- Chapter 25. Shell Scripting
- Chapter 26. Automating Tasks
- Chapter 27. Configuring and Building Kernels
- Chapter 28. Emulators, Tools, and Window Clients
- V. Appendixes
- A. The Linux Documentation Project
- B. Top Linux Commands and Utilities
- C. The GNU General Public License
- D. Red Hat Linux RPM Package Listings
Obtaining the Kernel Sources
Every Linux distribution contains kernel sources. Red Hat offers install options to include the kernel headers, and a separate RPM to include the kernel sources. You must install the kernel headers if you plan to compile any software; to build the kernel, you must also install the kernel-sources RPM, or obtain kernel sources from some other source.
When fetching kernel sources, it is good netiquette to seek a mirror site as close to you as possible. Although famous sites such as Red Hat (ftp://ftp.redhat.com) and kernel.org (ftp://ftp.kernel.org/pub/linux) will have the files you need, you should check http://www.kernel.org for an appropriate mirror site.
FTP mirrors partition kernel packages by major and minor version numbers such as /pub/linux/kernel/v2.4. Each directory contains whole-enchilada source tarballs and compressed patch files—if you are jumping up from 2.2 or 2.3, or if you want to start fresh, you need the file named linux-VERSION.tar.gz (or .bz2). Although a lot to download over a modem connection, once you have a standard source tree, you can update incrementally by downloading much smaller patch files.
Before you open any .tar file, you should always list the contents to see if the file is complete and to get an overview of the directory structure it will install:
$ tar -tzf linux-2.4.5.tar.gz
This will print a long list of files, including directories for device drivers, modules, and architecture-dependent code for all the current Linux ports as illustrated in Figure 27.1. The important detail is that the tarball unpacks into a directory called simply linux/.
Checklist for Coping with New Kernels
When dealing with new kernels, keep the following items in mind:
- Building and running the kernel depends on the software versions listed in linux/Documentation/Changes. Before you compile or run any new kernel, you can save a lot of heartache if you check your system against these version numbers!
- Drivers bundled with Linux may not be the very latest. If you have problems with a particular device, or with very new hardware, search for an update before building your kernel.
- Kernel changes may require changes to your boot scripts, to /etc/lilo.conf, or /etc/modules.conf. The linux/Documentation collection contains many short README files on many different parts of the kernel, and each driver subdirectory may also contain additional information on installing or configuring difficult devices. Most kernel modules accept parameters either through the bootparams, through the append line of /etc/lilo.conf, or, for dynamically loaded modules, on the /sbin/insmod command line or in /etc/modules.conf.
- If you give options both in lilo.conf and at the LILO: prompt, the boot prompt options are appended to the end of the append options. This allows you to override installed options at the command line to pre-empt unwanted settings; this is also why many modules also include options to restore their default behavior.
Example 27.1. Shell Script for Extracting Versions
#!/bin/sh
echo Versions 0.1 c.1999 by Gary Lawrence Murphy
echo ========================================================
/sbin/insmod -V 2>&1 | grep version | grep insmod
echo -n GCC:
gcc --version
ld -v
ls -l /lib/libc.so.* | gawk '{ print $9 $10 $11;} '
ldd --version 2>&1 | grep ldd
ls -l /usr/lib/libg++.so.* | gawk '{ print $9 $10 $11;} '
ps --version
procinfo -v
mount --version
hostname -V
basename --v
/sbin/automount --version
/sbin/showmount --version
bash -version
ncpmount -v
pppd -v
chsh -v
echo ========================================================
Source Tree Patches
Updates are distributed as patch files named for the version that results from the patch. For example, an upgrade from 2.4.4 to 2.4.5 will be called patch-2.4.5.gz. Patch files are simply context diffs, the output of the CVS or UNIX diff -c command (see man diff) which list the differences from the prior version. The patch is applied by piping the file through the GNU patch utility; the patch will be given lines of context around the change and told to delete, add, or replace lines in the source files.
There are two things you should know about patch files: They are much smaller than the source tarball (typically a few hundred kilobytes), and they do not always work.
Once you have patched the sources, you can bootstrap your new kernel configuration by copying your backup .config file to linux/.config and using make oldconfig to migrate the options present in your previous installation, preserving all those fiddly settings that are so often forgotten (such as the IRQ of your sound card!). You will need to monitor this process: make oldconfig will stop and prompt for any new options added by the new sources. Once this command has run, use make xconfig to recheck the settings, and then compile with any of the make build targets.
Upgrades and Modules
Modules are generally loaded automatically via kmod or scripted using /sbin/insmod program, with the obvious /sbin/rmmod to remove them. Other utilities in this suite include /sbin/depmod to compute module dependencies and /sbin/modprobe to load the module and those upon which it depends.
One of two module things can go wrong with a module when upgrading to a newer kernel:
- The module utilities are incompatible.
- The module dependencies may conflict.
The first situation is most likely. The ix386 module utilities have been updated to use PIII instructions and new editions may not have been included in your distribution files. If your module utilities meet the requirements spelled out in linux/Documentation/ Changes, you will have no problem, but if you do happen to boot a kernel with old module utilities, you can hang your system.
The second problem can hit anyone. This is one of those things that, once you know what has happened, you realize the solution is just common sense. For example, suppose you compile Windows VFAT filesystem support as a module, but then your boot scripts try to use some file from your windows partition prior to the module loading. Or, and more likely, you may accidentally attempt to load modules out of sequence. For instance, you might configure your network support as a module, forgetting that the httpd will hang the boot scripts while trying to resolve the hostname, and then inadvertently assign httpd an earlier slot in the /etc/rc.d/rc5.d boot sequence.
There is only a small overhead in loading and unloading and in the coding of a driver as a module. Unless memory or performance is critical, the code is needed continuously, or the module is required early in the boot process, it can and probably should be compiled as a module.
New Features in 2.4
If you are coming to this chapter from the 2.2 Kernel reference material, you're in for a ride. Systems have changed all over the place. The following is just a partial list of systems that have been added, rewritten, or rethought in the 2.4 kernel:
- Resource Management Subsystem
- Remapped Device Files
- Numerous Changes to the /proc Interface
- Support for 4.2 Billion Users
- Memory limit now 16GB
- I2O/PCI Improvements
- Improved Plug-and-Play Support
- Improved Parport Interface
- USB Support
- Extended Joystick Support
- ia64, S/390, and SuperH Ports
- Shared Memory VFS
- Logical Volume Manager
- Single Buffer File Caching
- Raw I/O Devices
- Large-file Filesystems (files > 2GB)
- UDF and UFS Filesystems
- SCSI Subsystem
- Module Access Control
- Network Address Translation (NAT)
- DECNet and ARCNet Support
- Direct Rendering Manager
- Voice Synthesizer Support
- Kernel-level HTTPD
- Documentation/DocBook and docgen
Planned Features for Linux 2.5
Kernels take time to polish for production, and books take time to prepare and print; as a result, there are many features that were either not ready in time to be considered for the 2.4 kernel, or that were not well understood enough to be included in this book prior to press. The following sections are a guess at some of the directions to be taken with 2.5, but do not be surprised if more than one finds its way into an early revision of 2.4.
CML2
If you have ever tried to add a new kernel feature, you have already seen why Eric Raymond is spending his flight and hotel time redesigning the kernel configuration tools.
CML2 is the Configuration Modeling Language to succeed the current make xconfig method with a simpler system, is easier to maintain and to program, and will allow module and service developers to specify all dependencies of their code. It may even be possible to specify your hardware to the CML2 interpreter and have it deduce the kernel options without intervention.
Frame Buffers (fbdev)
James Simmons has plans for cleaning up the fbdev layer with a new API, adding support for cards with multiple frame buffers, and adding real multihead support to the console system.
Sound System
Although partially present in 2.4, the next kernel will expand the support for the ALSA sound drivers.
V4L2
The 2.4 kernel contains little in the way of new support for the video and FM radio interface primarily because the developers are reworking the entire system for V4L2; unfortunately, V4L2 was not considered stable enough to be included into the 2.3 development tree and has been pushed back to Linux 2.5.
Memory Management and Memory Devices
Rik van Riel has plans to support allocating very large continuous memory blocks on system initialization, and improved dcache and other improvements to the VM. David Woodhouse is also calling for adding support for flash and other memory device drivers.
Journaling Filesystem
The 2.5 TODO list includes merging in the changes for the ReiserFS and ext3, merging in XFS, HFS+, JFS, and NWFS; whether all of these will happen or if some hybrid occurs remains to be seen.
Configuring the Linux Kernel | Next Section

Account Sign In
View your cart