Familiarizing Yourself with the Kernel

The Linux kernel is the software that allows application programs to communicate with the computer hardware and coexist with other running applications on the same system. To do that, the kernel must:

  • Know about the hardware drivers on the computer — In Linux, the code that lets applications communicate with each piece of computer hardware can either be built into the kernel as drivers or added to the kernel after it is running, using what are called loadable modules.

  • Be able to manage applications — By performing scheduling functions, the kernel can decide which running processes have access to the computer’s processor and for what duration. Processes are assigned priorities that can slow or speed the completion of those processes' requests.

  • Understand file systems and permissions — Because the kernel is responsible for letting processes read, write, and execute files that are stored in different types of file systems, the kernel must know about how those file systems are structured. It must also know the permissions each user has to access those files.

There are many other things that a kernel does. However, these three are some of the most obvious functions of the kernel to someone using a Linux system.

One of the best ways to learn about the kernel is to read files that are included with the kernel source code. The location of the kernel source code has changed between Fedora Core 2 and Fedora Core 3, and you have to unzip it and build it yourself. As root user from a terminal window, do the following:

  1. Install the kernel source package from the DVD that comes with this book (its name should be something like kernel-2.6.8-1.541.src.rpm from the SRPMS directory).

     # rpm -Uhv kernel-2.6.8-1.541.src.rpm 
  2. Type the following:

     # rpmbuild -bp --target noarch /usr/src/redhat/SPECS/kernel-2.6.spec 

Now, the kernel source code that you used to be able to find in /usr/src/linux is now available in the /usr/src/redhat/BUILD/kernel-* directory. Look in that directory for Documentation directory. It contains descriptions of many of the drivers and other components in the 2.6 kernel. You can use the code from this package to rebuild the Linux kernel as well.

Checking your current kernel

If you want to know what kernel your Linux system is currently running, you can type the uname -a command as follows:

 # uname -a Linux jukebox.linuxtoys.net 2.6.8-1.541 #1 Thu Nov 25 12:32:44 EDT 2004   i686 i686 i386 GNU/Linux 

This example shows the current kernel as 2.6.8-1.541. Because you can have multiple kernels available on your hard disk, each of which may require drivers and modules that are specific to that kernel, the kernel version number is used to store the compatible components. For example, you can look for directories named for your kernel version in:

  • /lib/modules — Modules that can be loaded as needed to support hardware connected to your computer are stored under the /lib/modules directory. One way that modules for the 2.6 kernel are different from the 2.4 kernel counterparts is that they end with a .ko extension (as opposed to a .o for 2.4 kernel modules). You can use the basename of themodules you find in kernel and unsupported subdirectories with the modinfo command to display descriptions of what hardware each driver supports.

  • /usr/src — If you install the kernel-source package (included on the DVD that comes with this book), a subdirectory of /usr/src that is named linux-2.6.* (where the asterisk is replaced by the revision level of the kernel), contains source code and documentation for your kernel. The Documentation subdirectory of that directory contains a wealth of information about the drivers and components that make up your kernel.

When you get the kernel with Fedora Core 3, it has already been built for you and stored in the /boot directory under the name vmlinuz-2.6.* (again, replacing the asterisk with the kernel revision level). Red Hat had to make some decisions about what drivers to include in the bootable kernel itself. Drivers that are needed for your particular hardware configuration can be detected after you boot Linux and can be added in the form of loadable modules.

Because there are some inefficiencies from using a kernel that includes drivers you don’t need, and must load drivers you do need, some Linux experts prefer to build their own kernels. In most cases, however, the performance gains are negligible, so most people simply take the small performance hits to load the modules they need at boot time.

If you do need to work with modules on your Linux system, you can use tools such as insmod (to install a module), modprobe (to install/remove a module along with any dependent modules), lsmod (to see what modules are installed), rmmod (to remove a module), or modinfo (to view information about a module). Those tools are described in Chapter 10.

Because, as I mentioned earlier, if the kernel is working well it should be nearly invisible to you, it helps to know what to look for to understand what you are gaining from the 2.6 kernel. The sections in this chapter break down Linux 2.6 kernel features by desktop, server, and other systems.

Using the /sys directory

The 2.6 kernel included a centralized approach to viewing the hardware connected to a Linux system. One way in which that centralized approach is reflected is in a new sysfs file system type that stores information about the hardware. In Fedora, and other Linux systems, that file systems is accessible under the /sys directory.

From the /sys directory, application programs (and even humans) can get the same view of devices that the kernel sees. Modifying values in many of the files in the /sys directory can change the way your system performs. Although the kernel itself and some utilities do most of the access and manipulation of the contents of the /sys directory, you can change data in some of those files yourself.

The files in the /sys directory contain such information as IRQ number, block sizes, and power management information. You can list the contents of these files to see how they are set (as in cat filename) or send new values to these files using the echo command (as in echo 123 > filename). Check the kernel Documentation directory (or do an online search) to read about the definitions of kernel parameters.


Remember, the kernel source code and documentation are in a different place than in previous Fedora releases, so follow the instructions earlier in the chapter to install and build kernel source code. The Documentation directory is here: /usr/src/redhat/BUILD/*/*/Documentation.

Red Hat Fedora Linux 3 Bible
Red Hat Fedora Linux 3 Bible
ISBN: 0764578723
EAN: 2147483647
Year: 2005
Pages: 286

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net