How to build a fedora kernel

Mar 9, 2009 by     3 Comments    Posted under: Technology

If you were ever interested in building custom kernel rpms for your machine i have detailed the process here with the minimal amount of steps.

First be sure you have the needed tools

  • yum-utils
  • rpm-build

Then download the latest kernel source

yumdownloader --source kernel

Once that is downloaded lets setup our local rpm tree



Extract and install the source

rpm -Uvh kernel-x.y.zz.ii-jjj.fcx.src.rpm


Execute the “%prep” stage from the spec file. Normally this involves unpacking the sources and applying any patches.

rpmbuild -bp --target=`uname -m` ~/rpmbuild/SPECS/kernel.spec


At this point we can setup our configuration to apply during the build.

cd ~/rpmbuild/BUILD/kernel-x.y.zz/linux-x.y.zz.`uname -m`/ make oldconfig make menuconfig


copy your configuration to the sources folder.

cp .config ~/rpmbuild/SOURCES/config-`uname -m`


and you are ready to build

rpmbuild -bb --with baseonly --without debuginfo --target=`uname -m` ~/rpmbuild/SPECS/kernel.spec



if you need to build the firmware module then change this line to this in the

%define with_firmware  %{?_with_firmware:     0} %{?!_with_firmware:     1}



Creating Patches
if you’d like to create a working copy to apply any custom test or patches, this will allow you to create a patch for your build.

cp -r ~/rpmbuild/BUILD/kernel-2.6.26/linux-2.6.26.x86_64 ~/rpmbuild/BUILD/kernel-2.6.26.dist cp -al ~/rpmbuild/BUILD/kernel-2.6.26.dist ~/rpmbuild/BUILD/ diff -uNrp ~/rpmbuild/BUILD/kernel-2.6.26/vanilla/{file} ~/rpmbuild/BUILD/{file} > {file}.patch




About Me

I have a passion for art, music, science and math. Really anything that makes me feel something. A mild mannered developer trying to slowly change the world. Apparently, very slowly.
Page Paul