(Turn) How to install or upgrade the latest kernel in CentOS 7 (I upgraded the kernel because the installation of docker was unsuccessful, and the installation of docker was successful after the upgrade)

https://linux.cn/article-8310-1.html

  Original address, Translator: geekpi  

While some people use Linux to mean an entire operating system, it's important to note that, strictly speaking, Linux is just a kernel. A distribution, on the other hand, is a fully functional system built on top of the kernel with a wide variety of application tools and libraries.

During normal operation, the kernel is responsible for performing two important tasks:

  1. Acts as the interface between the hardware and the software running on the system.
  2. Manage system resources as efficiently as possible.

To do this, the kernel communicates with the hardware through built-in drivers or drivers that can later be installed as modules.

For example, when a program running on your computer wants to connect to a wireless network, it submits that request to the kernel, which in turn uses the correct driver to connect to the network.

As new devices and technologies come out regularly, it is important to keep the kernel up to date if we want to take full advantage of them. Additionally, updating the kernel will help us take advantage of new kernel functions and protect ourselves from vulnerabilities found in previous versions.

Ready to update the kernel on CentOS 7 or its derivatives like RHEL 7 and Fedora? If so, keep reading!

Step 1: Check the installed kernel version

Let's install a distribution that includes a specific version of the kernel. To show the version currently installed on the system, we can:

 
 
  1. # uname -sr

The image below shows the output on a CentOS 7 server:

Check Kernel Version on CentOS 7

Check Kernel Version on CentOS 7

If we now go to  https://www.kernel.org/ , at the time of writing, we see that the latest kernel version is 4.10.1 (other versions are available from the same site).

An important thing to also consider is the lifetime of the kernel version - if the version you're currently using is nearing the end of its lifetime, no more bug fixes will be available after that date. See the Kernel Releases page for more information.

Step 2: Upgrade Kernel in CentOS 7

Most modern distributions provide a way to  upgrade the kernel using package management systems such as yum and officially supported repositories.

However, this will only upgrade the kernel to the latest version available in the repositories - not the latest version available at  https://www.kernel.org/  . Unfortunately, Red Hat only allows kernel upgrades using the former.

Unlike Red Hat, CentOS allows the use of ELRepo, a third-party repository that can upgrade the kernel to the latest version.

To enable the ELRepo repository on CentOS 7, run:

 
 
  1. # rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
  2. # rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm

Enable ELRepo on CentOS 7

Enable ELRepo on CentOS 7

Once the repository is enabled, you can list the available kernel-related packages with the following command:

 
 
  1. # yum --disablerepo="*" --enablerepo="elrepo-kernel" list available

yum - find out available kernel versions

yum - find out available kernel versions

Next, install the latest mainline stable kernel:

 
 
  1. # yum --enablerepo=elrepo-kernel install kernel-ml

Install Latest Kernel Version in CentOS 7

Install Latest Kernel Version in CentOS 7

Finally, reboot the machine and apply the latest kernel, then run the following command to check the latest kernel version:

 
 
  1. uname -sr

Verify kernel version

Verify kernel version

Step 3: Set GRUB default kernel version

To make the newly installed kernel the default boot option, you need to modify the GRUB configuration as follows:

Open and edit  /etc/default/grub and set  GRUB_DEFAULT=0. This means that the first kernel on which GRUB initializes a page will be the default kernel.

 
 
  1. GRUB_TIMEOUT=5
  2. GRUB_DEFAULT=0
  3. GRUB_DISABLE_SUBMENU=true
  4. GRUB_TERMINAL_OUTPUT="console"
  5. GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet"
  6. GRUB_DISABLE_RECOVERY="true"

Next run the following command to recreate the kernel configuration.

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

Setting up the kernel in GRUB

Setting up the kernel in GRUB

Reboot and verify that the latest kernel is the default kernel.

Boot Default Kernel Version in CentOS 7

Boot Default Kernel Version in CentOS 7

congratulations! You have upgraded the kernel in CentOS 7!

Summarize

In this article, we explained how to easily upgrade the Linux kernel on your system. We haven't covered another method, since it involves compiling the kernel from source, which could be written in a book, and is not recommended on production systems.

While it's one of the best learning experiences and allows for fine-grained configuration of the kernel, you may leave your system unusable and may have to reinstall it from scratch.

If you're still interested in building a kernel as a learning experience, you can get guidance on the  Kernel Newbies page.

As always, if you have any questions or comments about this article, please feel free to use the comment box below.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324613681&siteId=291194637