Fedora users usually have a relatively recent Linux Kernel installed on their system. Currently, this is Linux kernel 6.0. However, given Fedora is an upstream release and many users often install upstream distributions with newer hardware, you may want to pre-install the latest Linux kernel 6.1 mainline release for better hardware support. The new Linux Kernel release brings improvements and hardware support along with the initial Rust language support in the mainline Kernel for better security and memory-safe code.
Installing Linux Kernels should always be done if required, especially on Fedora systems. Often more things can go wrong than improve. Fedora is an upstream release so you will get the newest Kernel within a few weeks to a few months after testing, compared to other distributions focusing on long-term release Linux Kernels.
In the following tutorial, you will learn how to install Linux Kernel 6.1 on Fedora 37/36/35 Server or Workstation using the Fedora Rawhide development repository or the Linux Vanilla third-party repository that is well-known or using Fedora’s upstream, along with how to downgrade back to the original Fedora kernel if you run into issues.
Recommended Steps Before Installation
First, ensure your system is up-to-date using the following command below; this is essential when installing kernels.
sudo dnf upgrade --refresh
Next, you have two choices. Using the Fedora upstream method is probably more recommended but often not as quickly updated as the Vanilla Kernel repo, but for most users, that Kernel should work very well.
#1st Method: Install Linux Kernel 6.1 – Fedora Rawhide Repo
Users that do not want to use third-party kernels, often using the upstream latest bleeding edge kernel from the Fedora team, maybe a more desirable choice as these are designed to work with Fedora. The issue is that this is a development version in the Rawhide repository so it can be constantly prone to bugs.
First, run the following command to install the Fedora Rawhide upstream. Do not worry; your packages will not switch to the upstream. You still need to enable them to use the upstream; additionally, you can do the same for other packages if you desire.
sudo dnf install fedora-repos-rawhide -y
Now, let’s check what packages are available for the Linux Kernel from the Rawhide repository.
sudo dnf --enablerepo=rawhide info kernel
Example output:
Available Packages
Name : kernel
Version : 6.1.0
Release : 0.rc8.20221209git0d1409e4ff08.62.fc38
Architecture : x86_64
Size : 117 k
Source : kernel-6.1.0-0.rc8.20221209git0d1409e4ff08.62.fc38.src.rpm
Repository : rawhide
Summary : The Linux kernel
URL : https://www.kernel.org/
License : GPLv2 and Redistributable, no modification permitted
Description : The kernel meta package
As mentioned above, Linux Kernel 6.1 is available; now, run the following command to upgrade.
sudo dnf upgrade kernel --enablerepo=rawhide
Once done, reboot your system.
reboot
Once back, verify the kernel version installed.
cat /proc/version
Example output:
Linux version 6.1.0-0.rc8.20221209git0d1409e4ff08.62.fc38.x86_64 ([email protected]) (gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4), GNU ld version 2.39-6.fc38) #1 SMP PREEMPT_DYNAMIC Fri Dec 9 17:15:27 UTC 2022
Congratulations, you have installed Linux Kernel 6.1 using Fedora upstream.
Method 2: Install Linux Kernel 6.1 – Linux Vanilla Repo
Import Linux Vanilla Kernel Repo
Fedora often is up to date with the latest stable kernels. Usually, you will find upgrade kernels from Fedora in the testing repository or rawhide for future kernels, but they do not release overnight, even by Fedora’s standards.
For users that would like a quicker turnaround by using an RPM and not using the alternative XanMod or Liquorix type kernels or compiling your own, which for some users may be too complex or too time-consuming, the Linux Vanilla repo is often up to date with stable and mainline kernels and is well known.
Use the following command to import the repository on your Fedora system.
curl -s https://repos.fedorapeople.org/repos/thl/kernel-vanilla.repo | sudo tee /etc/yum.repos.d/kernel-vanilla.repo
If the command fails, you likely need to install the curl package, which you can do with the following command.
sudo dnf install curl -y
Install Linux Kernel 6.1
Currently, Linux Kernel 6.1 is featured on the mainline branch of the vanilla kernel. To begin the installation, use the following command.
sudo dnf config-manager --set-enabled kernel-vanilla-mainline
Note for your information for new users to Fedora and Linux mainly, and this will always feature the latest bleeding-edge Kernel.
Use the following command to set the stable repository for a higher priority than the default kernel repository.
sudo dnf config-manager --save --setopt="kernel-vanilla-mainline.priority=99"
Confirm that the priority was added.
grep priority /etc/yum.repos.d/kernel-vanilla.repo
Example output:
priority=99
None of the other repositories should have any priorities set by default, so you know the repository setup is successful if this is present.
Now upgrade the Linux mainline kernel.
sudo dnf upgrade kernel
As shown above, the Linux Kernel is now upgrading directly from the Vanilla Kernel repository. Type Y, then press the ENTER KEY to proceed.
Once done, reboot your system.
reboot
Once back, verify the kernel version installed.
cat /proc/version
Example output:
[[email protected] ~]$ cat /proc/version
Linux version 6.1.0-65.vanilla.1.fc37.x86_64 ([email protected]) (gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4), GNU ld version 2.38-25.fc37) #1 SMP PREEMPT_DYNAMIC Mon Dec 12 18:34:01 UTC 2022
Congratulations, you have installed the latest Linux Kernel, 6.1.
How to Restore Fedora Default Kernel
Remove Linux Kernel Vanilla
The below steps will show you a method to remove the installed third-party kernels and restore the default Fedora kernel. There may be other alternative ways, and this method will work, as shown below.
First, disable the enabled Linux Vanilla repository.
sudo dnf config-manager --set-disable kernel-vanilla-mainline
Fedora Rawhide can remove the repository if you have nothing else installed from it. Most likely, this should be the case, or else you are running Fedora Rawhide if you upgraded all the packages on your stable distribution, which you should not have done.
sudo dnf remove fedora-repos-rawhide
Alternatively, you can remove the Linux Vanilla repo instead of disabling it.
sudo rm /etc/yum.repos.d/kernel-vanilla.repo
Remove Linux Kernel 6.1 – Both Methods
First, run a quick DNF makecache to refresh the repositories.
sudo dnf makecache
Next, use the downgrade command to return to the Fedora Kernel.
sudo dnf downgrade kernel*
The output should look similar to the example below if you successfully reinstalled the default Linux Kernel on Fedora that was current on your system.
Reinstalled:
kernel-6.0.12-300.fc37.x86_64 kernel-core-6.0.12-300.fc37.x86_64 kernel-headers-6.0.5-300.fc37.x86_64 kernel-modules-6.0.12-300.fc37.x86_64
kernel-modules-extra-6.0.12-300.fc37.x86_64
Next, reboot your system.
reboot
Once logged back in, verify the installed Kernel using the cat command again.
cat /proc/version
Example output:
[[email protected] ~]$ cat /proc/version
Linux version 6.0.12-300.fc37.x86_64 ([email protected]) (gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4), GNU ld version 2.38-25.fc37) #1 SMP PREEMPT_DYNAMIC Thu Dec 8 16:58:47 UTC 2022
Now that you have restored the Fedora kernel, list the kernels present on Fedora that are installed and not in use.
dnf list kernel
Use the following command to remove both unused kernels.
sudo dnf --setopt=protected_packages= remove $(rpm -q kernel-core | grep -v $(uname -r))
Do not forget to reboot.
reboot
Run a quick dnf upgrade to ensure your default kernel is up-to-date.
sudo dnf upgrade kernel
Another good command to run distro-sync. The command is good for removing large or core-level packages such as kernels and getting your Fedora system back on track; use this as a last resort.
sudo dnf distro-sync
Conclusion
The tutorial has demonstrated two methods with cli commands to install either the Fedora Rawhide repository or the Linux Vanilla repository and install Linux Kernel 6.1 on Fedora 37/36/35. As mentioned at the start of the tutorial, only install the latest kernel mainline release on your Fedora system if you genuinely require it. For most, I would suggest just waiting a month or two for Fedora to test it, and most likely, it will be deployed on the current Fedora release.