Building your own kernel with the Fedora kernel configuration

May 11, 2007

There are a number of situations where you might want to do something like build a stock kernel.org kernel with the same configuration options as a normal Fedora RPM-installed kernel. Alternately, you want to compile a Fedora kernel with a slightly different set of options. These days, how to do this is slightly less than obvious and there is a gotcha or two.

First, you need kernel source. Fedora no longer ships an RPM with their kernel source all set up for you, so you have two options:

  • just download the version you want from kernel.org and unpack it somewhere convenient, or
  • fetch the kernel .src.rpm and set up to build it, which requires an RPM build environment. Once you have a kernel source RPM in your RPM build environment, you can get the source tree all patched up and ready to go with rpmbuild -bp kernel-2.6.spec.

Next, you need a kernel config file. The config file for a particular kernel RPM that you have installed is /boot/config-<release> (among other, less convenient places). However, if you are building by hand you don't want to use this configuration as it is, because if you try you will discover you wind up with a huge kernel image. The culprit is the CONFIG_DEBUG_INFO option, which causes the kernel to get compiled with -g; take it out following the directions in EasyKernelConfMods.

(The kernels in the RPMs are not this big because the RPM build process then strips the debugging info out and puts it in the kernel debuginfo RPM.)

If you are building a kernel.org kernel using a Fedora config file, there are two things to watch out for:

  • if you are upgrading kernel versions, make oldconfig will probably ask you about a number of new options.
  • make sure that you are using a base kernel version at least as recent as the Fedora kernel RPM. Fedora's current build practices do not put the subminor kernel version number in the RPM version (eg, the 2.6.20.8-based and 2.6.20.10-based kernel RPMs will both have an RPM version of just 2.6.20 plus a build sequence number), so you need to either inspect the kernel source RPM or the kernel RPM's changelog for the kernel you are running. You do the latter with:
    rpm -q --changelog kernel-`uname -r` | less

After that you are pretty much home free, assuming you are not rebuilding a kernel RPM. Doing that does not in any way fit into the margins of this entry.

Written on 11 May 2007.
« The other problem with network booting
Weekly spam summary on May 12th, 2007 »

Page tools: View Source, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Fri May 11 23:37:07 2007
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.