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.
[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.
Add the gpg key for elrepo
[root@liqiang.io]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
Add the source for elrepo
[root@liqiang.io]# yum install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
Check if the add was successful
[root@liqiang.io]# yum repolist | grep elre
elrepo ELRepo.org Community Enterprise Linux Repository - el8
When you see this, you’re OK.
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.
[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):.
[root@liqiang.io]# grubby --info ALL
index=0
kernel="/boot/vmlinuz-4.18.0-240.1.1.el8_3.x86_64"
args="ro no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop $tuned_params"
root="UUID=a62c5b49-755e-41b0-9d36-de3d95e17232"
initrd="/boot/initramfs-4.18.0-240.1.1.el8_3.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-240.1.1.el8_3.x86_64) 8"
id="99023f8aa5784c9c99a1c16aebb7ffa6-4.18.0-240.1.1.el8_3.x86_64"
index=1
kernel="/boot/vmlinuz-6.1.1-1.el8.elrepo.x86_64"
args="ro no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop $tuned_params"
root="UUID=a62c5b49-755e-41b0-9d36-de3d95e17232"
initrd="/boot/initramfs-6.1.1-1.el8.elrepo.x86_64.img $tuned_initrd"
title="Enterprise Linux (6.1.1-1.el8.elrepo.x86_64) 8.7"
id="37c50fab1ee34172b2980041f177dbda-6.1.1-1.el8.elrepo.x86_64"
index=2
kernel="/boot/vmlinuz-4.18.0-348.7.1.el8_5.x86_64"
args="ro no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop $tuned_params"
root="UUID=a62c5b49-755e-41b0-9d36-de3d95e17232"
initrd="/boot/initramfs-4.18.0-348.7.1.el8_5.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-348.7.1.el8_5.x86_64) 8"
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.
[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
[root@liqiang.io]# uname -msr
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: ``
[root@liqiang.io]# rpm -q kernel
kernel-4.18.0-240.1.1.el8_3.x86_64
kernel-4.18.0-348.7.1.el8_5.x86_64
[root@liqiang.io]# rpm -q kernel-ml
kernel-ml-6.1.1-1.el8.elrepo.x86_64
[root@liqiang.io]# dnf remove --oldinstallonly --setopt installonly_limit=2 kernel
[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.