Updating your Linux Kernel: Ubuntu, CentOS, Fedora, and Arch

Jarret B

Well-Known Member
Staff member
Joined
May 22, 2017
Messages
454
Reaction score
520
Credits
19,511
Most times, an updated kernel can make a system more stable by including updates and fixes to previous kernel builds.

For some, you may have software or device drivers that work, or are part of your kernel, only with specific kernels, but usually this is not the case.

So, to help improve stability and possibly performance, you should regularly check for updates to your kernel.

In this article, I will go over installing a newer kernel, if it exists, for the following distros:
  • Ubuntu
  • CentOS
  • Fedora
  • Arch
Check Your Kernel Version

To check the current version of your existing kernel, you can use the following command on all distros:

Code:
uname -r

The output will be the kernel version that is currently running. The output will not include other kernels that are installed, but not running.

The output, for example, on Ubuntu would be like:

Code:
6.14.0-29-generic

Ubuntu

The first time you manually want to check for an update, you will need to do the following steps to install the app 'mainline'.

Code:
sudo add-apt-repository ppa:cappelikan/ppa
sudo apt install mainline -y

Once you install the program, you only need to perform the following steps to perform a kernel update. Open the program 'Mainline Kernels'.

Once opened, you can see the list of kernels. The list should also show the installed kernels, whether they are currently running or not.

Find the kernel you want to install, select it and then click on the 'Install' button.

After you have installed all the kernels you wish to install, you can reboot so the kernel runs and you can test it. If a kernel does not work for you, you can use your boot loader to select a different kernel version at boot.

From within 'Mainline Kernels', you can also select any installed kernels and click on 'Uninstall' to remove the kernel version.

There is also a button labeled 'Uninstall Old' to remove the older kernels all at once.

CentOS

I used CentOS Stream 9, but the instructions will work for other versions; you just need to know your CentOS version. To get the version you have of either CentOS or Fedora, use the command that matches your distro:

Code:
cat /etc/centos-release
cat /etc/fedora-release

Use the 'uname -r' command to see your current Kernel Version. For example, my CentOS currently has the '5.14.0-599.el9.x86_64' kernel.

Before we install the packages, we need to set up keys for verification:

Code:
sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-v2-elrepo.org

NOTE: If you get a 404 error, then the address may be incorrect.

Now that we have the keys, we can install the package. This command depends on the version of the distro:

Code:
sudo dnf install https://www.elrepo.org/elrepo-release-#.el#.elrepo.noarch.rpm

NOTE: Be sure to replace the '#' signs with the version of your distro, such as '9' or even '10'. For example, if you have CentOS 9, then the command is 'sudo dnf install https://www.elrepo.org/elrepo-release-9.el9.elrepo.noarch.rpm'.

Once you complete these steps, you only need to run the last step each time you want to update the kernel.

Code:
sudo dnf --enablerepo=elrepo-kernel install kernel-ml

At any time, you can check the current version available with the following command:

Code:
sudo yum list available --disablerepo='*' --enablerepo=elrepo-kernel kernel-ml*

The resulting list should show the available versions in the second column, as shown in Figure 1.

Figure 1.jpg

FIGURE 1

The output shows the mainline kernels, but if you change 'kernel-ml' to 'kernel-lt', you'll get the listing of the long-term support kernel. If you want the lt' version, then just change the install command from 'ml' to 'lt'.

For a business, stick to the long-term version which are supported and stable. The main-line kernels may have more hardware support for newer hardware, but Red Hat does not support them. The main-line kernels have updates available more often, but may not be as stable as the long-term version.

This command will update the kernel to the newest mainline (ml) version. If you issue the command at any time, it can update the kernel if a newer one exists. If there is no newer kernel, then you get a message that the kernel is already up-to-date.

If you have a boot loader, such as GRUB, you need to update it if it does not perform auto-updates when you install new kernels. For example, you can use the command:

Code:
sudo grub2.mkconfig -o /boot/efi/EFI/centos/grub.cfg

Use the command you need for your specific boot loader.

After rebooting, I can use the 'uname -r' command and my kernel is now '6.16.4-1.el9.elrepo.x86_64'.

Fedora

Even though CentOS and Fedora are both based on Red Hat, the kernel updates are different on the two systems.

As usual, you need to see what kernel version you are starting with before continuing, so use 'uname -r'.

My kernel version is '6.16.4-100.fc41.x86_64'.

To start the kernel update, you need to stay in the terminal and perform the following two commands:

Code:
sudo dnf -y copr enable @kernel-vanilla/mainline
sudo dnf update

The first command adds a repository, and the second command updates the local repository lists from the existing repositories and the newly added one.

With the second command, if it prompts you to update files, then answer yes (y), as requested.

You can update your boot loader menu, such as GRUB, if needed, and reboot.

After rebooting, my kernel was '6.17.0-0.rc3.250831.c8bc81a5.134.vanilla.fc41.x86_64'.

When you perform any updates, they should update your kernel if a newer one exists.

The 'vanilla' kernels are close to those being released and do not have any Fedora modifications; which are patches, security modifications and optimizations made on them.

If you want the mainline Fedora kernel, when you do a system update it will be part of it, if a new kernel version exists.

The command to perform the update is:

Code:
sudo dnf upgrade

Arch

When updating the Arch system, it should automatically update the kernel.

To perform an update, for all system files and the kernel, use the command:

Code:
sudo pacman -Syu

After performing an update, you may need to update your boot loader before rebooting the system.

If you do not want the main-line kernel, then you can install a vanilla version, as we have covered the vanilla version above.

To do this, you need an AUR helper, such as 'yay'. For this, do the following after you update your packages from the repositories:

Code:
sudo pacman -S --needed base-devel git 
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

If the system prompts you about installing dependencies or the like, just accept the defaults.

The installation of the AUR helper may take a while to complete. Once it is complete, you can run 'yay' to update its repository lists.

To install the kernel, use the command:

Code:
yay -S linux-mainline

You can also install the long-term (lts) with the command:

Code:
yay -S linux-lts

You can get a listing of the latest kernel version with one of the following commands, depending on which type you prefer:

Code:
yay -Sss linux-mainline
yay -Sss linux-lts

For example, my current system is running version '6.16.4-arch1-1'. For the mainline version, I can install version '6.17rc4-1' and for the LTS version '6.12.44-1'.

The first time you run this command, there will be a lot of dependencies installed and keys imported. Keep close during the initial install since it will ask a lot for you to verify various steps.

The kernel install will take more time since the system compiles the kernel from source code.

If you have your 'initramfs' on a separate partition, you may need to build it yourself. Also, update the boot loader for the new kernel.

Checking the Kernel

After rebooting, you need to check the basic functionality of the system. Make sure all the hardware is working, such as:
  • display
  • keyboard/mouse
  • networking (wired/wireless)
  • Bluetooth
  • audio
  • USB ports
  • any other connected peripherals
As long as these work, you should be good. If there is an issue, then use your boot loader to load the previous kernel version that worked.

Another trick is that if there are boot issues, try a second time, just in case.

A good choice is to have a boot loader like GRUB that allows you to select a different kernel version if the current one has issues.

Conclusion

Some users like to keep their systems updated to the most current version of all the apps. Sometimes this includes the kernel.

With these instructions, you can keep your system up to date with a mainline or long-term-support kernel, depending on your preference and system use.

If you need a very stable version, you may stick to the version that is downloaded during a normal update, or even the LTS version.
 


but is it possible to update the kernel if I'm using Debian? (I don't want to use another distro)
 
Rather than saying Ubuntu, would not Debian be better as its the base for many distributions
 
but is it possible to update the kernel if I'm using Debian? (I don't want to use another distro)
I use the mainline tool (mentioned above) to update my Debian deployments, I normally follow the build process on their git page instead of using the apt route.

Works well and takes the stress out of the update process.
 
I use the mainline tool (mentioned above) to update my Debian deployments, I normally follow the build process on their git page instead of using the apt route.

Works well and takes the stress out of the update process.
ok


Does Debian each version they release in the future (Debian 11, Debian 12, Debian 13 and so on), does it comes with a updated version of the linux kernel or we still have to manually update it/compile it ourselves after we update the linux distro?
 
Does Debian each version they release in the future (Debian 11, Debian 12, Debian 13 and so on), does it comes with a updated version of the linux kernel or we still have to manually update it/compile it ourselves after we update the linux distro?
You get a new kernel version with each major update, I think the current release stays with the same kernel version but with minor updates. There's also Debian backports which allows you to install newer kernel versions but with back-ported patches.
 
we still have to manually update it/compile it ourselves after we update the linux distro?
if you are referring to Debian stable, then a new release comes with a newer kernel [but not the latest] this is for stability [as the name says] If you mean Debian testing then it will get regular updates, but be ready to spend a lot of time keeping it running
 
ok


Does Debian each version they release in the future (Debian 11, Debian 12, Debian 13 and so on), does it comes with a updated version of the linux kernel or we still have to manually update it/compile it ourselves after we update the linux distro?
They come with a base version that is in the image. Once newer versions come out for the kernel, you need to install them manually.
 
Most times, an updated kernel can make a system more stable by including updates and fixes to previous kernel builds.

For some, you may have software or device drivers that work, or are part of your kernel, only with specific kernels, but usually this is not the case.

So, to help improve stability and possibly performance, you should regularly check for updates to your kernel.

In this article, I will go over installing a newer kernel, if it exists, for the following distros:
  • Ubuntu
  • CentOS
  • Fedora
  • Arch
Check Your Kernel Version

To check the current version of your existing kernel, you can use the following command on all distros:

Code:
uname -r

The output will be the kernel version that is currently running. The output will not include other kernels that are installed, but not running.

The output, for example, on Ubuntu would be like:

Code:
6.14.0-29-generic

Ubuntu

The first time you manually want to check for an update, you will need to do the following steps to install the app 'mainline'.

Code:
sudo add-apt-repository ppa:cappelikan/ppa
sudo apt install mainline -y

Once you install the program, you only need to perform the following steps to perform a kernel update. Open the program 'Mainline Kernels'.

Once opened, you can see the list of kernels. The list should also show the installed kernels, whether they are currently running or not.

Find the kernel you want to install, select it and then click on the 'Install' button.

After you have installed all the kernels you wish to install, you can reboot so the kernel runs and you can test it. If a kernel does not work for you, you can use your boot loader to select a different kernel version at boot.

From within 'Mainline Kernels', you can also select any installed kernels and click on 'Uninstall' to remove the kernel version.

There is also a button labeled 'Uninstall Old' to remove the older kernels all at once.

CentOS

I used CentOS Stream 9, but the instructions will work for other versions; you just need to know your CentOS version. To get the version you have of either CentOS or Fedora, use the command that matches your distro:

Code:
cat /etc/centos-release
cat /etc/fedora-release

Use the 'uname -r' command to see your current Kernel Version. For example, my CentOS currently has the '5.14.0-599.el9.x86_64' kernel.

Before we install the packages, we need to set up keys for verification:

Code:
sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-v2-elrepo.org

NOTE: If you get a 404 error, then the address may be incorrect.

Now that we have the keys, we can install the package. This command depends on the version of the distro:

Code:
sudo dnf install https://www.elrepo.org/elrepo-release-#.el#.elrepo.noarch.rpm

NOTE: Be sure to replace the '#' signs with the version of your distro, such as '9' or even '10'. For example, if you have CentOS 9, then the command is 'sudo dnf install https://www.elrepo.org/elrepo-release-9.el9.elrepo.noarch.rpm'.

Once you complete these steps, you only need to run the last step each time you want to update the kernel.

Code:
sudo dnf --enablerepo=elrepo-kernel install kernel-ml

At any time, you can check the current version available with the following command:

Code:
sudo yum list available --disablerepo='*' --enablerepo=elrepo-kernel kernel-ml*

The resulting list should show the available versions in the second column, as shown in Figure 1.

View attachment 27925
FIGURE 1

The output shows the mainline kernels, but if you change 'kernel-ml' to 'kernel-lt', you'll get the listing of the long-term support kernel. If you want the lt' version, then just change the install command from 'ml' to 'lt'.

For a business, stick to the long-term version which are supported and stable. The main-line kernels may have more hardware support for newer hardware, but Red Hat does not support them. The main-line kernels have updates available more often, but may not be as stable as the long-term version.

This command will update the kernel to the newest mainline (ml) version. If you issue the command at any time, it can update the kernel if a newer one exists. If there is no newer kernel, then you get a message that the kernel is already up-to-date.

If you have a boot loader, such as GRUB, you need to update it if it does not perform auto-updates when you install new kernels. For example, you can use the command:

Code:
sudo grub2.mkconfig -o /boot/efi/EFI/centos/grub.cfg

Use the command you need for your specific boot loader.

After rebooting, I can use the 'uname -r' command and my kernel is now '6.16.4-1.el9.elrepo.x86_64'.

Fedora

Even though CentOS and Fedora are both based on Red Hat, the kernel updates are different on the two systems.

As usual, you need to see what kernel version you are starting with before continuing, so use 'uname -r'.

My kernel version is '6.16.4-100.fc41.x86_64'.

To start the kernel update, you need to stay in the terminal and perform the following two commands:

Code:
sudo dnf -y copr enable @kernel-vanilla/mainline
sudo dnf update

The first command adds a repository, and the second command updates the local repository lists from the existing repositories and the newly added one.

With the second command, if it prompts you to update files, then answer yes (y), as requested.

You can update your boot loader menu, such as GRUB, if needed, and reboot.

After rebooting, my kernel was '6.17.0-0.rc3.250831.c8bc81a5.134.vanilla.fc41.x86_64'.

When you perform any updates, they should update your kernel if a newer one exists.

The 'vanilla' kernels are close to those being released and do not have any Fedora modifications; which are patches, security modifications and optimizations made on them.

If you want the mainline Fedora kernel, when you do a system update it will be part of it, if a new kernel version exists.

The command to perform the update is:

Code:
sudo dnf upgrade

Arch

When updating the Arch system, it should automatically update the kernel.

To perform an update, for all system files and the kernel, use the command:

Code:
sudo pacman -Syu

After performing an update, you may need to update your boot loader before rebooting the system.

If you do not want the main-line kernel, then you can install a vanilla version, as we have covered the vanilla version above.

To do this, you need an AUR helper, such as 'yay'. For this, do the following after you update your packages from the repositories:

Code:
sudo pacman -S --needed base-devel git
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

If the system prompts you about installing dependencies or the like, just accept the defaults.

The installation of the AUR helper may take a while to complete. Once it is complete, you can run 'yay' to update its repository lists.

To install the kernel, use the command:

Code:
yay -S linux-mainline

You can also install the long-term (lts) with the command:

Code:
yay -S linux-lts

You can get a listing of the latest kernel version with one of the following commands, depending on which type you prefer:

Code:
yay -Sss linux-mainline
yay -Sss linux-lts

For example, my current system is running version '6.16.4-arch1-1'. For the mainline version, I can install version '6.17rc4-1' and for the LTS version '6.12.44-1'.

The first time you run this command, there will be a lot of dependencies installed and keys imported. Keep close during the initial install since it will ask a lot for you to verify various steps.

The kernel install will take more time since the system compiles the kernel from source code.

If you have your 'initramfs' on a separate partition, you may need to build it yourself. Also, update the boot loader for the new kernel.

Checking the Kernel

After rebooting, you need to check the basic functionality of the system. Make sure all the hardware is working, such as:
  • display
  • keyboard/mouse
  • networking (wired/wireless)
  • Bluetooth
  • audio
  • USB ports
  • any other connected peripherals
As long as these work, you should be good. If there is an issue, then use your boot loader to load the previous kernel version that worked.

Another trick is that if there are boot issues, try a second time, just in case.

A good choice is to have a boot loader like GRUB that allows you to select a different kernel version if the current one has issues.

Conclusion

Some users like to keep their systems updated to the most current version of all the apps. Sometimes this includes the kernel.

With these instructions, you can keep your system up to date with a mainline or long-term-support kernel, depending on your preference and system use.

If you need a very stable version, you may stick to the version that is downloaded during a normal update, or even the LTS version.
Hello. I just installed mainline because the update to 6.17 kernel has no WiFi. Nor does 6.14.0-37 which did. But I was fooling around today regarding this problem and somehow i did something so that 6.14 has no WiFi either.

I installed 6.16, but it doesn't show up on the GRUB screen when I go do Advanced Options for LINUX. How do I get it to show all installed kernels so I can choose from it?
 
Hello. I just installed mainline because the update to 6.17 kernel has no WiFi. Nor does 6.14.0-37 which did. But I was fooling around today regarding this problem and somehow i did something so that 6.14 has no WiFi either.

I installed 6.16, but it doesn't show up on the GRUB screen when I go do Advanced Options for LINUX. How do I get it to show all installed kernels so I can choose from it?
Did you update grub after installing the latest kernel that you installed?
If not, then updating grub should enable grub to see it and have it placed in the menu.

Perhaps check whether it is indeed installed in the /boot directory, though I'd expect it's there.
 
And by installing kernel from AUR without knowing what exactly you're doin' you can completely break your system! :D Cuz just installin' linux-mainline or linux-lts ain't enough. You gotta run
Code:
sudo mkinitcpio -P
to rebuild the boot images

OR

install the package named 'dkms' ("Dynamic Kernel Module Support") which will run the above command for you every time you install new kernel (or update it) and all you gotta do is just reboot. Also, the dkms package requires kernel headers which is unclear whether the kernel from AUR includes. If it doesn't, you'll have to rebuild the boot images manually with the above command, otherwise dkms will return a bunch of errors and then you'll definitely get the black screen I mentioned below.

Without mkinitcpio -P (and that's ONLY if you're lucky) the system will boot up but it won't boot up with the new kernel you just installed bc there won't be an existing boot image for it. If you have zero luck, the system simply won't boot and all you'll get would be a black screen with blinkin' underscore in the top left corner of the screen.
 
Last edited:
Quite so, and a good point. ;)

If I am on a Debian-based distro (includes Ubuntu and Linux Mint), and I am actively installing a newer kernel manually, I run

Code:
sudo update-initramfs

and

Code:
sudo update-grub

If I am doing same with Arch-base distros, I use

Code:
sudo mkinitcpio -P

as @rado84 has said above, instead of the initramfs command above.

Also, be aware that Mainline is the descendant of UKUU, an Ubuntu tool (Ubuntu Kernel Upgrade Utility).

It uses the PPA (Personal Package Archive) cappelikan , that the OP has mentioned.

BUT

(and Wizard's but usually follows close behind him)

Debian by default is not designed to use PPAs.

To add one, you need to first be sure you have

software-properties-common

installed.

Further, manipulating Debian in that way, you run a level of risk in creating a FrankenDeb , so be warned.

Wizard
 
Quite so, and a good point. ;)

as @rado84 has said above, instead of the initramfs command above.

Wizard
I just included something about dkms I forgot to mention before and which is quite important, especially with AUR. When packages are pre-compiled and from the official repos, dkms pulls dependencies on its own but with AUR you never know what the maintainer was thinking when writing the dependencies. There's a reason AUR comes without any guarantees and that's just one of them.
 


Follow Linux.org

Staff online

Members online


Latest posts

Top