Switch Kernel for Fedora(40)
A few days ago, I upgraded from Fedora 39 to Fedora 40. However, after the upgrade, my VirtualBox could not start properly due to a mismatch between the kernel and kernel-header versions.
By using uname -r and dnf list --installed | grep "kernel-headers", I found out the versions are as follows:
kernel: 6.8.8-300.fc40.x86_64kernel-headers: 6.8.3-300.fc40.x86_64
I tried to install the matching version of kernel-headers using sudo dnf install kernel-headers-$(uname -r), but found that there was no corresponding version available.1
Consequently, I decided to downgrade the kernel version to match the available kernel-headers. After verifying its existence, I attempted to install kernel version 6.8.3-300.fc40 using sudo dnf install kernel-6.8.3-300.fc40.x86_64, but dnf indicated that this version was unavailable.
Ultimately, I found a solution on discussion.fedoraproject (opens in a new tab), where information from Fedora Updates System For F40 (opens in a new tab) allowed verification of the required kernel version, which could then be installed using koji download-build --arch=x86_64 <package name>. The process is as follows:
mkdir kernel-downloadscd kernel-downloadskoji download-build --arch=x86_64 kernel-6.8.3-300.fc40sudo dnf install ./kernel-*Upon completion, it was necessary to switch to the newly installed kernel version. This could be managed using sudo grubby --info=ALL to view the list of system kernels, noting the desired index and kernel. For example:

Next, a temporary switch to this kernel was made to ensure everything was working properly:2
sudo grub2-reboot "3"rebootIf everything functioned as expected, this kernel could be set as the default:
sudo grubby --set-default /boot/vmlinuz-6.8.3-300.fc40.x86_64A final check to confirm the default setting was successful:
sudo grubby --default-kernelFrom this point on, our system will use the 6.8.3-300.fc40 version of the kernel by default until a dnf update is performed or another version is manually selected.
Reference:
- https://discussion.fedoraproject.org/t/how-do-i-install-an-old-kernel/76942/3 (opens in a new tab)
- https://knowledgebase.frame.work/en_us/change-default-fedora-kernel-H1Jnv0n6 (opens in a new tab)
Footnotes
-
This can also be confirmed on fedoraproject/rpms/kernel (opens in a new tab) and fedoraproject/rpms/kernel-headers (opens in a new tab), where the latest version of
kernel-headersfor Fedora 40 is6.8.3-300.fc40. ↩ -
The above command sets the system to boot from
kernelatindex3on the next reboot (effective for one time only). ↩
Reply to this post on X (opens in a new tab)View as Markdown