Menguji Patch

wchilders@nearce.com, Rowan Puttergill Version F44 Last review: 2026-07-15
Panduan singkat untuk menguji apakah sebuah patch menyelesaikan masalah Anda.

Kadang-kadang, ketika mencoba menyelesaikan masalah kernel (terutama yang spesifik pada perangkat keras Anda), Anda mungkin diminta untuk menerapkan sebuah patch untuk memverifikasi apakah masalah tersebut telah diperbaiki sebelum patch tersebut dimasukkan.

Ini adalah panduan singkat tentang cara mendapatkan sumber kernel Fedora untuk versi Fedora Anda, menerapkan patch, dan membangun kernel untuk diuji. Panduan ini ditujukan bagi pengguna yang tidak akrab dengan proses pengembangan kernel Fedora, dan hanya memerlukan pemahaman dasar tentang alat yang terkait.

Persiapan Awal

Pertama, jika belum terpasang, Anda perlu menginstal fedpkg (utilitas pemaketan RPM milik Fedora):

$ sudo dnf install fedpkg

Selanjutnya, Anda perlu mengambil kode sumber (langkah ini akan membuat subdirektori baru bernama "kernel" dan meletakkan semua berkas yang diperlukan di sana):

$ 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

Lalu, masuk ke direktori "kernel" yang telah dibuat:

$ cd kernel

Setelah berada di direktori kernel, Anda perlu berpindah ke cabang (branch) untuk versi Fedora Anda dengan menggunakan perintah berikut, di mana "<fedora version>" adalah versi Fedora Anda:

$ fedpkg switch-branch f<fedora version>

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

$ fedpkg switch-branch f44

Terakhir, Anda perlu menambahkan akun Anda ke grup "mock" menggunakan perintah berikut, di mana "<username>" adalah nama pengguna Fedora Anda:

$ 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 -

Menerapkan Patch

Untuk menerapkan patch, ambil berkas .patch yang diminta untuk Anda terapkan, dan simpan di direktori "kernel" yang dibuat pada langkah sebelumnya dengan nama:

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

Membangun Paket

Untuk membangun paket kernel, pastikan Anda sudah berada di direktori "kernel".

Langkah berikutnya mungkin memakan waktu cukup lama, jadi pastikan Anda memiliki waktu luang di mana komputer dapat bekerja tanpa gangguan.

Kemudian, jalankan perintah berikut:

$ fedpkg mockbuild

Akhirnya, silakan nikmati minuman hangat, berjalan-jalan, bermain dengan hewan peliharaan Anda, atau bersantai dan kembali nanti.

Menginstal Paket

Untuk menginstal paket, pastikan Anda berada di direktori "kernel". Dari sana, masuk ke direktori "results_kernel":

$ cd results_kernel

Direktori ini akan berisi satu subdirektori dengan nama versi kernel. Gunakan perintah ls untuk mengetahui namanya, misalnya:

$ ls
7.1.3

Masuk ke direktori tersebut:

$ cd 7.1.3

Ulangi proses ini sekali lagi:

$ 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

Daftarnya sekarang seharusnya terlihat seperti ini:

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

Terakhir, instal semua paket rpm di direktori ini menggunakan dnf:

$ sudo dnf install ./*.rpm

Menguji Kernel

Setelah semuanya berhasil diinstal, lakukan reboot. Kernel yang telah Anda bangun seharusnya otomatis dipilih oleh GRUB saat sistem Anda dinyalakan. Biarkan komputer melakukan boot, lalu periksa apakah masalah Anda telah teratasi.

Kembali ke Versi Sebelumnya

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.