Installing the Linux Kernel 6.x on CentOS 7

Kernel is central component of an operating system that manages operations of computer and hardware. It basically manages operations of memory and CPU time. It is core component of an operating system. Kernel acts as a bridge between applications and data processing performed at hardware level using inter-process communication and system calls.

Step 1 - Find Current Kernel Version

Run the following command to know your current kernel:

uname -sr

Output:

[root@vps ~]# uname -sr
Linux 3.10.0-1160.66.1.el7.x86_64

Step 2 - Enable ELRepo Repository

To enable the ELRepo repository on CentOS 7, do:

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

yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm

Output:

[root@vps ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@vps ~]# yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
Loaded plugins: fastestmirror
elrepo-release-7.el7.elrepo.noarch.rpm                                                                         | 8.7 kB  00:00:00
Examining /var/tmp/yum-root-3qbisw/elrepo-release-7.el7.elrepo.noarch.rpm: elrepo-release-7.0-6.el7.elrepo.noarch
Marking /var/tmp/yum-root-3qbisw/elrepo-release-7.el7.elrepo.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package elrepo-release.noarch 0:7.0-6.el7.elrepo will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================
 Package                     Arch                Version                       Repository                                        Size
======================================================================================================================================
Installing:
 elrepo-release              noarch              7.0-6.el7.elrepo              /elrepo-release-7.el7.elrepo.noarch              5.0 k

Transaction Summary
======================================================================================================================================
Install  1 Package

Total size: 5.0 k
Installed size: 5.0 k

Once the repository has been enabled, you can use the following command to list the available kernel related packages:

yum --disablerepo="*" --enablerepo="elrepo-kernel" list available

Output:

 [root@vps ~]# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
 Loaded plugins: fastestmirror
Determining fastest mirrors
 * elrepo-kernel: repos.lax-noc.com
elrepo-kernel                                                                                         | 3.0 kB  00:00:00
elrepo-kernel/primary_db                                                                              | 2.1 MB  00:00:00
Available Packages
kernel-lt.x86_64                                              5.4.228-1.el7.elrepo                              elrepo-kernel
kernel-lt-devel.x86_64                                        5.4.228-1.el7.elrepo                              elrepo-kernel
kernel-lt-doc.noarch                                          5.4.228-1.el7.elrepo                              elrepo-kernel
kernel-lt-headers.x86_64                                      5.4.228-1.el7.elrepo                              elrepo-kernel
kernel-lt-tools.x86_64                                        5.4.228-1.el7.elrepo                              elrepo-kernel
kernel-lt-tools-libs.x86_64                                   5.4.228-1.el7.elrepo                              elrepo-kernel
kernel-lt-tools-libs-devel.x86_64                             5.4.228-1.el7.elrepo                              elrepo-kernel
kernel-ml.x86_64                                              6.1.1-1.el7.elrepo                                elrepo-kernel
kernel-ml-devel.x86_64                                        6.1.1-1.el7.elrepo                                elrepo-kernel
kernel-ml-doc.noarch                                          6.1.1-1.el7.elrepo                                elrepo-kernel
kernel-ml-headers.x86_64                                      6.1.1-1.el7.elrepo                                elrepo-kernel
kernel-ml-tools.x86_64                                        6.1.1-1.el7.elrepo                                elrepo-kernel
kernel-ml-tools-libs.x86_64                                   6.1.1-1.el7.elrepo                                elrepo-kernel
kernel-ml-tools-libs-devel.x86_64                             6.1.1-1.el7.elrepo                                elrepo-kernel
perf.x86_64                                                   5.4.228-1.el7.elrepo                              elrepo-kernel
python-perf.x86_64                                            5.4.228-1.el7.elrepo                              elrepo-kernel

Step 3 - Install Kernel

Run the following command to install the latest mainline stable kernel:

yum --enablerepo=elrepo-kernel install kernel-ml

Output:

[root@vps ~]# yum --enablerepo=elrepo-kernel install kernel-ml
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: la.mirrors.clouvider.net
 * elrepo: repos.lax-noc.com
 * elrepo-kernel: repos.lax-noc.com
 * extras: mirror.keystealth.org
 * updates: mirrors.unifiedlayer.com
base                                                                                                  | 3.6 kB  00:00:00
elrepo                                                                                                | 3.0 kB  00:00:00
extras                                                                                                | 2.9 kB  00:00:00
updates                                                                                               | 2.9 kB  00:00:00
(1/5): base/7/x86_64/group_gz                                                                         | 153 kB  00:00:00
(2/5): elrepo/primary_db                                                                              | 415 kB  00:00:00
(3/5): extras/7/x86_64/primary_db                                                                     | 249 kB  00:00:00
(4/5): base/7/x86_64/primary_db                                                                       | 6.1 MB  00:00:00
(5/5): updates/7/x86_64/primary_db                                                                    |  19 MB  00:00:12
Resolving Dependencies
--> Running transaction check
---> Package kernel-ml.x86_64 0:6.1.1-1.el7.elrepo will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================
 Package                    Arch                    Version                             Repository                      Size
=============================================================================================================================
Installing:
 kernel-ml                  x86_64                  6.1.1-1.el7.elrepo                  elrepo-kernel                   60 M

Transaction Summary
=============================================================================================================================
Install  1 Package

Total download size: 60 M
Installed size: 284 M
Is this ok [y/d/N]: y
Downloading packages:
kernel-ml-6.1.1-1.el7.elrepo.x86_64.rpm                                                               |  60 MB  00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : kernel-ml-6.1.1-1.el7.elrepo.x86_64                                                                       1/1
  Verifying  : kernel-ml-6.1.1-1.el7.elrepo.x86_64                                                                       1/1

Installed:
  kernel-ml.x86_64 0:6.1.1-1.el7.elrepo

Complete!

Step 4 - Set the Latest Kernel as Default

There are 2 ways to set default kernel

Method 1 :

To make the newly-installed version the default boot option, you will have to modify the GRUB configuration as follows:

Open and edit the file /etc/default/grub and set GRUB_DEFAULT=0. This means that the first kernel in the GRUB list will be used as default.

vi /etc/default/grub

To insert/edit the file enter 'i' for insert mode and insert the following at End Of Fle. After inserting, save the file by hitting Esc key and then ':' [colon] followed by wq and enter

:wq

Output:

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
Grub_DEFAULT=0
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

Method 2 :

On this method we see how to set kernel as default using command

To list kernel

ls -l /boot/vmlinuz-*

Output:

[root@vps ~]# ls -l /boot/vmlinuz-*
-rwxr-xr-x. 1 root root 9581728 Jan  2 16:02 /boot/vmlinuz-0-rescue-a6d50446f33f06f1eb05c40863b2fd2e
-rwxr-xr-x. 1 root root 6769256 Dec 28 16:44 /boot/vmlinuz-0-rescue-ebe37f940c964f47810cc9eebe34643b
-rwxr-xr-x. 1 root root 7047784 Dec 16 17:33 /boot/vmlinuz-3.10.0-1160.81.1.el7.x86_64
-rwxr-xr-x. 1 root root 9581728 Dec 31 14:37 /boot/vmlinuz-6.1.1-1.el7.elrepo.x86_64

Set The default kernel using the kernel filename:

Note Replace index_number with kernel index number that need to be set as default.

grubby --set-default kernel_filename

Output:

[root@vps ~]# grubby --set-default /boot/vmlinuz-6.1.1-1.el7.elrepo.x86_64

Step 5 - Rebuild the Configuration File

Run the following command to recreate the kernel configuration:

grub2-mkconfig -o /boot/grub2/grub.cfg

Output:

[root@vps ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.1.1-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-6.1.1-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.66.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.66.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-540897c06a504053ab186e27caa799e1
Found initrd image: /boot/initramfs-0-rescue-540897c06a504053ab186e27caa799e1.img
Found linux image: /boot/vmlinuz-0-rescue-c52fc00695191b701c0ff16463b012ac
Found initrd image: /boot/initramfs-0-rescue-c52fc00695191b701c0ff16463b012ac.img
done

Reboot and verify that the latest kernel is now being used by default using the uname command again:

uname -sr

Output:

[root@vps ~]# uname -sr
[Linux 6.1.1-1.el7.elrepo.x86_64
[root@vps ~]#    

CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS