initCommon(); $template->displayHeader(); ?>

8. Linux Kernel

This section covers changes and important information regarding the 2.6.18 based kernel in Fedora Core 6. The 2.6.18 kernel includes:

8.1. Version

Fedora Core may include additional patches to the kernel for improvements, bug fixes, or additional features. For this reason, the Fedora Core kernel may not be line-for-line equivalent to the so-called vanilla kernel from the kernel.org web site:

http://www.kernel.org/

To obtain a list of these patches, download the source RPM package and run the following command against it:

rpm -qpl kernel-<version>.src.rpm

8.2. Changelog

To retrieve a log of changes to the package, run the following command:

rpm -q --changelog kernel-<version>

If you need a user friendly version of the changelog, refer to http://wiki.kernelnewbies.org/LinuxChanges. A short and full diff of the kernel is available from http://kernel.org/git. The Fedora version kernel is based on the Linus tree.

Customizations made for the Fedora version are available from http://cvs.fedora.redhat.com .

8.3. Kernel Flavors

Fedora Core 6 includes the following kernel builds:

  • Native kernel, for use in most systems. Configured sources are available in the kernel-devel-<version>.<arch>.rpm package.

  • kernel-PAE, for use in 32-bit x86 systems with > 4GB of RAM, or with CPUs that have a 'NX (No eXecute)' feature. This kernel support both uniprocessor and multi-processor systems.

  • Virtualization kernel for use with the Xen emulator package. Configured sources are available in the kernel-xen-devel-<version>.<arch>.rpm package.

  • Kdump kernel for use with kexec/kdump capabilities. Configured sources are available in the kernel-kdump-devel-<version>.<arch>.rpm package.

You may install kernel headers for all kernel flavors at the same time. The files are installed in the /usr/src/kernels/<version>-[xen|kdump]-<arch>/ tree. Use the following command:

su -c 'yum install kernel-{PAE,xen,kdump}-devel'

Select one or more of these flavors, separated by commas and no spaces, as appropriate. Enter the root password when prompted.

[Note]Default Kernel Provides SMP

There is no separate SMP kernel available for Fedora Core 6 on i386, x86_64 and ppc64. Multiprocessor support is provided by the native kernel.

[Note]PowerPC Kernel Support

There is no support for Xen or kdump for the PowerPC architecture in Fedora Core 6 test3. 32-bit PowerPC does still have a separate SMP kernel.

8.4. Reporting Bugs

Refer to http://kernel.org/pub/linux/docs/lkml/reporting-bugs.html for information on reporting bugs in the Linux kernel. You may also use http://bugzilla.redhat.com for reporting bugs that are specific to Fedora.

8.5. Following Generic Textbooks

Many of the tutorials, examples, and textbooks about Linux kernel development assume the kernel sources are installed under the /usr/src/linux/ directory. If you make a symbolic link, as shown below, you should be able to use those learning materials with the Fedora Core packages. Install the appropriate kernel sources, as shown earlier, and then run the following command:

su -c 'ln -s /usr/src/kernels/<version>.<release>-<arch> /usr/src/linux'

Enter the root password when prompted.

8.6. Preparing for Kernel Development

Fedora Core 6 does not include the kernel-source package provided by older versions since only the kernel-devel package is required now to build external modules. Configured sources are available, as described in this kernel flavors section.

[Note]Instructions Refer to Current Kernel

To simplify the following directions, we have assumed that you want to configure the kernel sources to match your currently-running kernel. In the steps below, the expression <version> refers to the kernel version shown by the command: uname -r.

Users who require access to Fedora Core original kernel sources can find them in the kernel .src.rpm package. To create an exploded source tree from this file, perform the following steps:

[Note]Do Not Build Packages as Super-user (root)

Building packages as the superuser is inherently dangerous and is not required, even for the kernel. These instructions allow you to install the kernel source as a normal user. Many general information sites refer to /usr/src/linux in their kernel instructions. If you use these instructions, simply substitute ~/rpmbuild/BUILD/kernel-<version>/linux-<version>.<arch>."]]

  1. Prepare a RPM package building environment in your home directory. Run the following commands:

    su -c 'yum install rpmdevtools yum-utils' 
    rpmdev-setuptree
  2. Enter the root password when prompted.

  3. Download the kernel-<version>.src.rpm file. Enable any appropriate source repositories, such as Core, Updates, or Testing, with the -e switch:

    yumdownloader -e core-source -e updates-source --source kernel
  4. Enter the root password when prompted.

  5. Install kernel-<version>.src.rpm using the command:

    rpm -Uvh kernel-<version>.src.rpm
  6. This command writes the RPM contents into ${HOME}/rpmbuild/SOURCES and ${HOME}/rpmbuild/SPECS, where ${HOME} is your home directory.

    [Note]Space Required

    The full kernel building process may require several gigabytes of extra space on the file system containing your home directory.

  7. Prepare the kernel sources using the commands:

    cd ~/rpmbuild/SPECS 
    rpmbuild -bp --target $(uname -m) kernel-2.6.spec
  8. The kernel source tree is located in the ~/rpmbuild/BUILD/kernel-<version>/linux-<version>.<arch> directory.

    The configurations for the specific kernels shipped in Fedora Core 6 are in the ~/rpmbuild/BUILD/kernel-<version>/linux-<version>.<arch>/configs directory. For example, the i686 configuration file is named ~/rpmbuild/BUILD/kernel-<version>/linux-<version>.<arch>/configs/kernel-<version>-i686.config. Issue the following command to place the desired configuration file in the proper place for building:

    cp configs/<desired-config-file> .config
  9. Every kernel gets a name based on its version number. This is the value the uname -r command displays. The kernel name is defined by the first four lines of the kernel Makefile. The Makefile has been changed to generate a kernel with a different name from that of the running kernel. To be accepted by the running kernel, a module must be compiled for a kernel with the correct name. To do this, you must edit the kernel Makefile.

    For example, if the uname -r returns the string 2.6.17-1.2345_FC6, change the EXTRAVERSION definition from this:

    EXTRAVERSION = -prep 

    to this:

    EXTRAVERSION = -1.2345_FC6

    That is, substitute everything from the final dash onward.

  10. Run the following command:

    make oldconfig

    You may then proceed as usual.

[Note]Building Kernel Binary RPMs

Normally, kernels for Fedora are built using the rpmbuild utility and a specfile. Your results may vary if you use the kernel's built-in make rpm target.

8.7. Building Only Kernel Modules

An exploded source tree is not required to build a kernel module, such as your own device driver, against the currently in-use kernel. Only the kernel-devel package is required to build external modules. If you did not select it during installation, use Pirut to install it, going to ApplicationsAdd/Remove Software or use yum to install it. Run the following command to install the kernel-devel package using yum.

su -c 'yum install kernel-devel' 

For example, to build the foo.ko module, create the following Makefile in the directory containing the foo.c file:

obj-m := foo.o 

KDIR  := /lib/modules/$(shell uname -r)/build
PWD   := $(shell pwd)

default:
    $(MAKE) -C $(KDIR) M=$(PWD) modules

Issue the make command to build the foo.ko module.

displayFooter('$Date: 2007/02/06 03:00:19 $'); ?>