Testing Patches

wchilders@nearce.com, Rowan Puttergill Version F44 Last review: 2026-07-15
A quick guide for testing if a patch resolves your issue.

Occasionally, when attempting to resolve a kernel issue (particularly one that’s specific to your hardware) you may be asked to apply a patch to verify that the issue is fixed before the patch is included.

This is a brief guide on how to get ahold of the Fedora kernel source for your version of Fedora, apply the patch, and build a kernel to test. This guide is aimed at users not familiar with the Fedora kernel development process, and requires only minimal understanding of the associated tooling.

Getting Setup

First if not already installed, you’re going to install fedpkg (Fedora’s RPM packaging utility):

$ sudo dnf install fedpkg

Next, you’re going to get ahold of the source (this will create a new subdirectory "kernel" and place all necessary files there):

$ fedpkg clone --anonymous kernel

The mock utility is used to build the packages from the kernel source. On a system where SELinux is enforcing, you must ensure that the file contexts are properly set on the directory where your kernel sources will be located.

$ sudo semanage fcontext -a -t mock_var_lib_t kernel
$ sudo restorecon -R kernel

Then, enter the created directory "kernel":

$ cd kernel

After entering the kernel directory, you need to switch to the branch for your current version of Fedora using the following command where "<fedora version>" is your version of Fedora:

$ fedpkg switch-branch f<fedora version>

For instance, if you’re running Fedora 44, you’d run:

$ fedpkg switch-branch f44

Finally, you need to add yourself to the "mock" group using the following command where "<username>" is your Fedora username:

$ sudo usermod -a -G mock <username>

For this change to take effect you can either logout and log back in, or you can run the following command and then open a new shell session or terminal:

$ newgrp -

Applying The Patch

To apply the patch, take the .patch file you’ve been requested to apply, and save it in the "kernel" directory the previous step created as:

linux-kernel-test.patch

Set the Kernel Buildid

To avoid conflicts with existing kernels, set a custom buildid by editing the kernel.spec file in the "kernel" directory.

Find the line that matches # define buildid .local and change it to %define buildid .<your_custom_id>.

Note that <your_custom_id> should be a numeric build ID and is used to identify your kernel build, against other Fedora-built kernels, and can help prevent conflicts when switching between kernels or doing package installation.

You can use sed to make this change directly, for example:

$ sed -i 's/# define buildid .local/%define buildid .1000/' kernel.spec

Building The Packages

To build the kernel packages, first make sure you’re in the "kernel" directory.

This next step may take a while so be sure to wait until you’ve got some time where you can let your computer work.

Then, run the following command:

$ fedpkg mockbuild

Finally, go enjoy a hot beverage, take a walk, play with your dog, or otherwise relax and come back later.

Installing The Packages

To install the packages, first make sure you’re in the "kernel" directory. From there you’re going to enter the "results_kernel" directory:

$ cd results_kernel

This directory will contain a single subdirectory that’s the kernel version number. Use the ls command to find its name, for example:

$ ls
7.1.3

Enter this directory:

$ cd 7.1.3

Repeat this process once more:

$ ls
201.1000.fc44
$ cd 201.1000.fc44

Finally, if you run ls one more time, you’ll see several ".rpm" files. As an example:

build.log
hw_info.log
installed_pkgs.log
kernel-7.1.3-201.1000.fc44.x86_64.rpm
kernel-7.1.3-201.1000.fc44.x86_64.rpm
kernel-core-7.1.3-201.1000.fc44.x86_64.rpm
kernel-debug-7.1.3-201.1000.fc44.x86_64.rpm
kernel-debug-core-7.1.3-201.1000.fc44.x86_64.rpm
kernel-debug-debuginfo-7.1.3-201.1000.fc44.x86_64.rpm
kernel-debug-devel-7.1.3-201.1000.fc44.x86_64.rpm
kernel-debug-devel-matched-7.1.3-201.1000.fc44.x86_64.rpm
kernel-debuginfo-7.1.3-201.1000.fc44.x86_64.rpm
kernel-debuginfo-common-x86_64-7.1.3-201.1000.fc44.x86_64.rpm
kernel-debug-modules-7.1.3-201.1000.fc44.x86_64.rpm
kernel-debug-modules-core-7.1.3-201.1000.fc44.x86_64.rpm
kernel-debug-modules-extra-7.1.3-201.1000.fc44.x86_64.rpm
kernel-debug-modules-internal-7.1.3-201.1000.fc44.x86_64.rpm
kernel-debug-uki-virt-7.1.3-201.1000.fc44.x86_64.rpm
kernel-debug-uki-virt-addons-7.1.3-201.1000.fc44.x86_64.rpm
kernel-devel-7.1.3-201.1000.fc44.x86_64.rpm
kernel-devel-matched-7.1.3-201.1000.fc44.x86_64.rpm
kernel-modules-7.1.3-201.1000.fc44.x86_64.rpm
kernel-modules-core-7.1.3-201.1000.fc44.x86_64.rpm
kernel-modules-extra-7.1.3-201.1000.fc44.x86_64.rpm
kernel-modules-extra-matched-7.1.3-201.1000.fc44.x86_64.rpm
kernel-modules-internal-7.1.3-201.1000.fc44.x86_64.rpm
kernel-selftests-internal-7.1.3-201.1000.fc44.x86_64.rpm
kernel-tools-7.1.3-201.1000.fc44.x86_64.rpm
kernel-tools-debuginfo-7.1.3-201.1000.fc44.x86_64.rpm
kernel-tools-libs-7.1.3-201.1000.fc44.x86_64.rpm
kernel-tools-libs-devel-7.1.3-201.1000.fc44.x86_64.rpm
kernel-uki-virt-7.1.3-201.1000.fc44.x86_64.rpm
kernel-uki-virt-addons-7.1.3-201.1000.fc44.x86_64.rpm
libperf-7.1.3-201.1000.fc44.x86_64.rpm
libperf-debuginfo-7.1.3-201.1000.fc44.x86_64.rpm
libperf-devel-7.1.3-201.1000.fc44.x86_64.rpm
perf-7.1.3-201.1000.fc44.x86_64.rpm
perf-debuginfo-7.1.3-201.1000.fc44.x86_64.rpm
python3-kernel-tools-7.1.3-201.1000.fc44.x86_64.rpm
python3-perf-7.1.3-201.1000.fc44.x86_64.rpm
python3-perf-debuginfo-7.1.3-201.1000.fc44.x86_64.rpm
root.log
rtla-7.1.3-201.1000.fc44.x86_64.rpm
rtla-debuginfo-7.1.3-201.1000.fc44.x86_64.rpm
rv-7.1.3-201.1000.fc44.x86_64.rpm
rv-debuginfo-7.1.3-201.1000.fc44.x86_64.rpm
state.log

Make a directory to store the RPM files that you don’t intend to use, such as the .src.rpm and *devel files, and move these files into the directory with the following commands:

$ mkdir dev
$ mv *.src.rpm dev
$ mv *devel*.rpm dev
$ mv *debug*.rpm dev

The list now should now look something like this:

build.log
dev
hw_info.log
installed_pkgs.log
kernel-7.1.3-201.1000.fc44.x86_64.rpm
kernel-core-7.1.3-201.1000.fc44.x86_64.rpm
kernel-modules-7.1.3-201.1000.fc44.x86_64.rpm
kernel-modules-core-7.1.3-201.1000.fc44.x86_64.rpm
kernel-modules-extra-7.1.3-201.1000.fc44.x86_64.rpm
kernel-modules-extra-matched-7.1.3-201.1000.fc44.x86_64.rpm
kernel-modules-internal-7.1.3-201.1000.fc44.x86_64.rpm
kernel-selftests-internal-7.1.3-201.1000.fc44.x86_64.rpm
kernel-tools-7.1.3-201.1000.fc44.x86_64.rpm
kernel-tools-libs-7.1.3-201.1000.fc44.x86_64.rpm
kernel-uki-virt-7.1.3-201.1000.fc44.x86_64.rpm
kernel-uki-virt-addons-7.1.3-201.1000.fc44.x86_64.rpm
libperf-7.1.3-201.1000.fc44.x86_64.rpm
perf-7.1.3-201.1000.fc44.x86_64.rpm
python3-kernel-tools-7.1.3-201.1000.fc44.x86_64.rpm
python3-perf-7.1.3-201.1000.fc44.x86_64.rpm
root.log
rtla-7.1.3-201.1000.fc44.x86_64.rpm
rv-7.1.3-201.1000.fc44.x86_64.rpm
state.log

Finally, install all the rpm packages in this directory using dnf:

$ sudo dnf install ./*.rpm

Testing The Kernel

Once everything is installed successfully, reboot. The kernel you built should automatically be selected by GRUB when your system starts up. Simply allow your computer to boot, and check to see if your issue has been resolved.

Going Back

If you’ve finished testing, and you’d like to revert to the previous kernel you can change the default kernel in grub by using grubby.

It is important to remove your test kernel to avoid future conflicts and to allow your system to update easily in future.

Check which kernels are available on the system:

$ sudo grubby --info=ALL

index=0
kernel="/boot/boot/vmlinuz-6.19.10-300.fc44.x86_64"
args="no_timer_check console=tty1 console=ttyS0,115200n8 systemd.firstboot=off rootflags=subvol=root"
root="UUID=15c26993-ac30-424a-9c4b-faec4434d234"
initrd="/boot/boot/initramfs-6.19.10-300.fc44.x86_64.img"
title="Fedora Linux (6.19.10-300.fc44.x86_64) 44 (Cloud Edition)"
id="b208e0c02ac84ca1a2150fc5ec1fa60e-6.19.10-300.fc44.x86_64"
index=1
kernel="/boot/boot/vmlinuz-7.1.3-201.1000.fc44.x86_64"
args="ro rootflags=subvol=root no_timer_check console=tty1 console=ttyS0,115200n8 systemd.firstboot=off rootflags=subvol=root"
root="UUID=15c26993-ac30-424a-9c4b-faec4434d234"
initrd="/boot/boot/initramfs-7.1.3-201.1000.fc44.x86_64.img"
title="Fedora Linux (7.1.3-201.1000.fc44.x86_64) 44 (Cloud Edition)"
id="4d3467c7ecab402cbe8242a1413beb27-7.1.3-201.1000.fc44.x86_64"

Use the index to identify the kernel that you want as default, and set it as follows:

$ sudo grubby --set-default-index=0
The default is /boot/loader/entries/b208e0c02ac84ca1a2150fc5ec1fa60e-6.19.10-300.fc44.x86_64.conf with index 0 and kernel /boot/boot/vmlinuz-6.19.10-300.fc44.x86_64

Reboot the system.

Check that the system is running the intended kernel:

$ uname -r
6.19.10-300.fc44.x86_64

If you’re using the kernel you intended, use the following command to undo installing the kernel:

$ sudo dnf history undo last

You should then be prompted to remove the kernel packages you just installed. If you see other packages, use dnf history to find the transaction to undo. You’re looking for the number at the start of a line that includes the kernel version that was installed:

$ dnf history --reverse
...
7 dnf install ./kernel-7.1.3-201.1000.fc44.x86_64.rpm ./kernel-core-7.1.3-201.1000.fc44.x86_64.rpm ...

This number "7" can then be used to undo via the following command:

$ sudo dnf history undo 7

Check that the kernel that you created with the patch has been removed from grub:

$ sudo grubby --info=ALL
index=0
kernel="/boot/boot/vmlinuz-6.19.10-300.fc44.x86_64"
args="no_timer_check console=tty1 console=ttyS0,115200n8 systemd.firstboot=off rootflags=subvol=root"
root="UUID=15c26993-ac30-424a-9c4b-faec4434d234"
initrd="/boot/boot/initramfs-6.19.10-300.fc44.x86_64.img"
title="Fedora Linux (6.19.10-300.fc44.x86_64) 44 (Cloud Edition)"
id="b208e0c02ac84ca1a2150fc5ec1fa60e-6.19.10-300.fc44.x86_64"

Finally if you reboot, the new kernel (e.g., 7.1.3-201.1000) should no longer appear in GRUB.