Install fedora-rpmdevtools (as root) from Fedora Extras.
yum install fedora-rpmdevtools
Create Build Directories Run fedora-buildrpmtree as a
regular user to create
the rpmbuild directory tree in your home
directory.
fedora-buildrpmtree
Get the Source
Get kernel-XXX.src.rpm from a SRPMS directory of your favorite Fedora mirror.
![]() |
Note |
|---|---|
|
After Fedora Core 2 kernel-source-XXX.rpm does NOT exist. |
|
Install Source
(as regular user) Use rpm to install the kernel source code.
rpm -ivh kernel-XXX.src.rpm
Change build options (Optional)
Edit the spec file
(~/rpmbuild/SPECS/kernel-XXX.spec)
to enable or disable different build options.
Example for simple build: no SMP, no Xen, no docs, no kdump. Changes from default are highlighted in yellow.
%define buildup 1
%define buildsmp 0
# Whether to apply the Xen patches, leave this enabled.
%define includexen 1
# Whether to build the Xen kernels, disable if you want.
%define buildxen 0
%define buildxenPAE 0
%define builddoc 0
%define buildkdump 0
Note: Leave "includexen" defined as "1" even if you do not want to build the Xen kernels. Applying some patches seems to fail if you change it to 0.
Also, if building an i686 non-SMP kernel, find this block (around line 70) and change buildsmp to 0
%ifarch i686
%define buildsmp 0
%endif
Customize Release name (Optional)
Edit ~/rpmbuild/SPECS/kernel-XXX.spec to customize the
release name of the kernel you are building. For example, add your username to the end of the release name.
%define release %(R="$Revision: 1.2157 $"; RR="${R##: }"; echo ${RR%%?})_FC5.username
Prepare Build
Use the rpmbuild prep stage to apply any patches and configure the kernel exactly as it is in the Fedora distribution.
rpmbuild -bp --target=ARCH ~/rpmbuild/SPECS/kernel-XXX.spec
Reconfigure the kernel
Use one of the kernel configuration interfaces (menuconfig, xconfig, etc.) to make changes to the kernel configuration.
cd ~/rpmbuild/BUILD/kernel-XXX/linux-XXX/
make xconfig
![]() |
Note |
|---|---|
|
Some of the configuration interfaces require other packages, menuconfig requires ncurses-devel, xconfig requires qt-devel, and gmenu requires gtk2-devel. |
|
(x86 architectures) Edit the .config file
The first line of .config needs "i386" on the first line. Edit the file to make sure it looks like this.
# i386
Copy .config file and Return to home directory
The entire source tree,
including .config, will be overwritten
before the actual build, so copy .config to
the SOURCES directory replacing the original configuration for your
architecture. Return to home directory because the directory you are in
will be automatically deleted and created again in the next step.
cp .config ~/rpmbuild/SOURCES/kernel-XXX-ARCH.config
cd
Build The Kernel
The -bb option to rpmbuild will build the kernel binary package performing every rpm build stage along the way but with the new configuration.
rpmbuild -bb --target=ARCH ~/rpmbuild/SPECS/kernel-XXX.spec
![]() |
Note |
|---|---|
|
The option -ba should be used to make a source rpm if the new kernel will be distributed. |
|
Install the Kernel RPM
(as root) Install the kernel rpm (and kernel-devel rpm if needed). Do not upgrade or otherwise replace a working kernel.rpm -ivh ~/rpmbuild/RPMS/ARCH/kernel-2.6.XXX.NAME.rpm
rpm -ivh ~/rpmbuild/RPMS/ARCH/kernel-devel-2.6.XXX.NAME.rpm