I previously wrote about upgrading the kernel on CentOS 7, but some of the actions no longer work on CentOS 8, so I’m putting together another version on CentOS 8.

Step 1: Upgrade the system software

As a regular operation, the first step is definitely to upgrade the system’s original software first, because some subsequent steps may depend on some installed software to reduce subsequent troubles, so you need to perform the following upgrade operation.

  1. [root@liqiang.io]# dnf update -y

Step 2: Add elrepo sources

To upgrade the kernel, you must have a source. Here I use the elrepo source, which is added by the following steps.

Step 3: Install the new kernel

Now you can start installing the new kernel. For the sake of other sources, you need to specify the source when you use it.

  1. [root@liqiang.io]# dnf --enablerepo="elrepo-kernel" install -y kernel-ml

Once installed, you’re done.

Step 4: Setting up grub2

In step 3 I have installed the new kernel, and now I can look at all the kernels on the system, this step is a bit different from CentOS 7 (but I didn’t look very hard to understand why it’s different):.

  1. [root@liqiang.io]# grubby --info ALL
  2. index=0
  3. kernel="/boot/vmlinuz-4.18.0-240.1.1.el8_3.x86_64"
  4. args="ro no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop $tuned_params"
  5. root="UUID=a62c5b49-755e-41b0-9d36-de3d95e17232"
  6. initrd="/boot/initramfs-4.18.0-240.1.1.el8_3.x86_64.img $tuned_initrd"
  7. title="CentOS Linux (4.18.0-240.1.1.el8_3.x86_64) 8"
  8. id="99023f8aa5784c9c99a1c16aebb7ffa6-4.18.0-240.1.1.el8_3.x86_64"
  9. index=1
  10. kernel="/boot/vmlinuz-6.1.1-1.el8.elrepo.x86_64"
  11. args="ro no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop $tuned_params"
  12. root="UUID=a62c5b49-755e-41b0-9d36-de3d95e17232"
  13. initrd="/boot/initramfs-6.1.1-1.el8.elrepo.x86_64.img $tuned_initrd"
  14. title="Enterprise Linux (6.1.1-1.el8.elrepo.x86_64) 8.7"
  15. id="37c50fab1ee34172b2980041f177dbda-6.1.1-1.el8.elrepo.x86_64"
  16. index=2
  17. kernel="/boot/vmlinuz-4.18.0-348.7.1.el8_5.x86_64"
  18. args="ro no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop $tuned_params"
  19. root="UUID=a62c5b49-755e-41b0-9d36-de3d95e17232"
  20. initrd="/boot/initramfs-4.18.0-348.7.1.el8_5.x86_64.img $tuned_initrd"
  21. title="CentOS Linux (4.18.0-348.7.1.el8_5.x86_64) 8"
  22. id="37c50fab1ee34172b2980041f177dbda-4.18.0-348.7.1.el8_5.x86_64"

I have set the new kernel as the default boot here, you need to set it with this step if you follow this installation and find that the new kernel is not the default.

  1. [root@liqiang.io]# grubby --args amd_iommu=on --update-kernel 2

The number 0 after this first sentence sets which kernel is the default kernel, then you reboot the system and you will see that the system will boot from the new kernel by default if you do not intervene manually.

After booting, you can check the current kernel version at

  1. [root@liqiang.io]# uname -msr
  2. Linux 6.1.1-1.el8.elrepo.x86_64 x86_64

[Optional] Step 5: Remove an old version of the kernel

If you feel that older versions of the kernel are taking up space for you, then it is worth removing them, and the way to do this is simple: ``

  1. [root@liqiang.io]# rpm -q kernel
  2. kernel-4.18.0-240.1.1.el8_3.x86_64
  3. kernel-4.18.0-348.7.1.el8_5.x86_64
  4. [root@liqiang.io]# rpm -q kernel-ml
  5. kernel-ml-6.1.1-1.el8.elrepo.x86_64
  6. [root@liqiang.io]# dnf remove --oldinstallonly --setopt installonly_limit=2 kernel
  7. [root@liqiang.io]#

However, when I finished the upgrade and was ready to compile and install the rest of the software, the problem arose, no matter what I did, the version of kernal-devel that the compiler relied on was old.

Reference