Product SiteDocumentation Site

7.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.

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:

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' 
  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.

    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.

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.