The primary source of information on building a custom kernel in fedora is here. This post will step you through that with an additional step to add the patches you may need.
Get the source
First, where-ever you feel like, clone the kernel packaging source, for example:
cd ~ && mkdir projects && cd ~/projects
fedpkg clone -a kernel
Then cd in to the new directory and checkout the required branch matching the fedora release number you need:
git checkout origin/f36
To save work with git (not a compulsory step, but will help with updating), do:
git checkout -b patch-f36
git branch -u origin/f36
Prepare for build
sudo dnf install fedpkg fedora-packager rpmdevtools ncurses-devel pesign grubby
sudo dnf builddep kernel.spec
kernel.spec is where you will do most of the work, so open up that file in your
favourite text editor which is vim and search for this line:
# define buildid .local
and replace it with:
%define buildid .local
then a few hundred or so lines further down the file you will find a block like this:
This is where you will need to add patches, an example is adding the
patch required for ASUS laptops with the 0x1866 device (N-Key Keyboard). So below the
line above add:
# ROG Laptops
and lastly, the patches must be in the same directory as
You need to also add them before the
# END OF PATCH APPLICATIONS
line in the existing block like-so:
and then build using
fedpkg --release f36 local --without debug --without debuginfo --with release (remember to replace f36 with the branch you checked out).
To customize a kernel, edit
kernel-local for example:
If building from a third-party repo you may require
--name kernel --namespace rpms (after
# This file is intentionally left empty in the stock kernel. Its a nicety
# added for those wanting to do custom rebuilds with altered config opts.
All the rpm packages will be located in
~/projects/kernel/x86_64/, it's likely that
you will need to install all except the debug packages.
If you have any work to save,
git commit it, or
git stash pop if you stashed work.