Product SiteDocumentation Site

7.7. Preparing for Kernel Development

Fedora Core 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> .
  1. Prepare a RPM package building environment in your home directory. Run the following commands:
    su -c 'yum install fedora-rpmdevtools yum-utils'
    fedora-buildrpmtree
    
    
    Enter the root password when prompted.
  2. Enable the appropriate source repository definition. In the case of the kernel released with Fedora Core 5, enable core-source by editing the file /etc/yum.repos.d/fedora-core.repo, setting the option enabled=1. In the case of update or testing kernels, enable the source definitions in /etc/yum.repos.d/fedora-updates.repo or /etc/yum.repos.d/fedora-updates-testing.repo as appropriate.
  3. Download the kernel-<version>.src.rpm file:
    yumdownloader --source kernel
    
    
    Enter the root password when prompted.
  4. Install kernel-<version>.src.rpm using the command:
    rpm -Uvh kernel-<version>.src.rpm
    
    
    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.
  5. Prepare the kernel sources using the commands:
    cd ~/rpmbuild/SPECS
    rpmbuild -bp --target $(uname -m) kernel-2.6.spec
    
    
    The kernel source tree is located in the ${HOME}/rpmbuild/BUILD/kernel-<version>/ directory.
  6. The configurations for the specific kernels shipped in Fedora Core are in the configs/ directory. For example, the i686 SMP configuration file is named configs/kernel-<version>-i686-smp.config . Issue the following command to place the desired configuration file in the proper place for building:
    cp configs/<desired-config-file> .config
    
    
    You can also find the .config file that matches your current kernel configuration in the /lib/modules/<version>/build/.config file.
  7. 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.15-1.1948_FC5 , change the EXTRAVERSION definition from this:
    EXTRAVERSION = -prep
    
    
    to this:
    EXTRAVERSION = -1.1948_FC5
    
    
    That is, substitute everything from the final dash onward.
  8. Run the following command:
    make oldconfig
    
    
    You may then proceed as usual.