[Turn] [Linux] kernel Linux CentOS 7 upgrade

https://blog.csdn.net/kikajack/article/details/79396793

References 1 upgrade CentOS kernel 
upgrade CentOS kernel references 2 
through / proc virtual file system to read or configure the kernel 
Linux kernel official website 
CentOS official website

1. About Linux kernel
Linux kernel in two ways: the official kernel (kernel developers usually use) and major Linux kernel release (the average user used).

The official 1.1 kernel
when using Docker, found that the minimum requirements for the Linux kernel version is 3.10 (which also happens to be the CentOS kernel version 7.2), but there are some features not implemented in this version. Currently the Linux kernel has been released to 4.X (you can always view the current version of the Linux kernel in the official website), in order to use the latest version of the kernel, had to install CentOS 7 After the kernel upgrade.

Of course, the kernel can not choose the latest, to prevent BUG has not been found. And in order to reduce future maintenance to stop the trouble, it is best to install long-term support version. Various versions of support in time to see this page. Each version may have four types, summarized as follows:

Prepatch: Prepatch or "RC" kernel is a major pre-release version of the kernel, mainly for kernel developers and Linux enthusiasts. It must be compiled from the source code, and usually contains new functions must be tested before it can be placed in a stable version. Prepatch kernel maintained and published by Linus Torvalds.
Mainline: Mainline mainline tree maintained by Linus Torvalds. This version of the kernel will introduce all the new features. The new kernel Mainline published once every 2-3 months.
Stable: After each mainline kernel was released, it is deemed to be "stable". Any stable kernel BUG repair will be back from Mainline mainline tree specified by the stable kernel maintenance personnel. Before the next mainline available, usually only a few BUG fix kernel version - unless it is designated as a "longterm maintenance kernel (the core of long-term maintenance)." stable kernel update released on demand, usually 2-3 times a month.
Longterm: usually provide several "longterm maintenance" kernel version, for BUG repair the old version of the kernel. These cores will repair major BUG, and does not frequent releases.
Longterm release of the kernel:

Maintainer version release date of the project life cycle
4.14 Greg Kroah-Hartman 2017-11-12 Jan, 2020
4.9 Greg Kroah-Hartman 2016-12-11 Jan, 2019
4.4 Greg Kroah-Hartman 2016-01-10 Feb, 2022
4.1 Sasha Levin May 2015-06-21, 2018
3.16 Ben Hutchings 2014-08-03 Apr, 2020
3.2 Ben Hutchings 2012-01-04 May, 2018
1.2 kernel major Linux distributions
in general, only download from kernel.org and compile and install the kernel is the official kernel. 
Most Linux distributions provide their own maintenance kernel, and so on can be upgraded via yum or rpm package management systems. These cores may no longer be the official Linux kernel developers and maintainers have a relationship. Through this support by the major Linux distribution warehouses to upgrade the kernel, usually it is more simple and reliable, but also an alternative version of the kernel less.

Use uname -r distinguish you use the official kernel or Linux kernel distributions, there is nothing behind the dash have said that this is not the official kernel:

Uname -r #
3.10.0-514.26.2.el7.x86_64

2. View the current kernel version
2.1 Overview
Linux kernel only that. The major Linux distributions (RedHat, Ubuntu, CentOS, etc.) based on the kernel integrates a range of other software, released under the respective versions of the rules. For example in CentOS 7.2, when viewing through kernel version uname -r, will see 3.10.0-514.26.2.el7.x86_64, it represents the Linux kernel version is 3.10.

2.2 Frequently used commands to view kernel messages
2.2.1 uname
prints the specified system information. Used without parameters, default -s parameter. 
Parameters: 
-a, -all: print all information in the following order, if -p and -i is unknown excluded. 
-s, -kernel-name: print the kernel name, usually is Linux. 
-n, -nodename: host name of the print network nodes. 
-r, -kernel-release: print version of the kernel release. Commonly used. 3.10.0-514.26.2.el7.x86_64 
-v, -kernel-Version: print version of the kernel. 1 SMP Tue Jul 4 # 15:04:05 UTC 2017 
-m, -machine: hardware printer name. 
-p, -processor: print processor name or "unknown". 
-i, -hardware-platform: print the hardware platform or "unknown". 
-o, -operating-system: the printing operating system. 
-Help: display this help and exit. 
-Version: display this version information and exit.

Example:

Uname -r #
3.10.0-514.26.2.el7.x86_64
# uname -a
Linux VM_139_74_centos 3.10.0-514.26.2.el7.x86_64 # 1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 the GNU / Linux
# CAT / etc / RedHat-Release 
CentOS Linux Release 7.2.1511 (core) 

2.2.2 / proc virtual file system
kernel space and user space via / proc virtual file system can communicate. 
/ proc directory contains virtual directories and files, these files can be presented kernel virtual information to the user or to send information from user space to the kernel. 
Common file:

cpuinfo: identifies the type and speed of the processor
PCI: display devices found on the PCI bus
modules: the kernel module is loaded into the current
system version and kernel version: version
Example:

CAT # / proc / Version 
Linux Version 3.10.0-514.26.2.el7.x86_64 ([email protected]) (20,150,623 gcc Version 4.8.5 (Red Hat 4.8.5-11) (GCC)) 1 SMP Tue Jul 4 # 15:04:05 UTC 2017

3. backup data
4. upgrading the kernel
remember the first update repository:

Update -y yum

-y option every time you need to confirm, automatically yes, to save time.

4.1 Warehouse enabled ELRepo
ELRepo warehouse is based on RedHat Enterprise (RHEL) and other RHEL based Linux distributions (CentOS, Scientific, Fedora, etc.) of community support for Enterprise Linux warehouse, provide right. 
ELRepo focused on packages and associated hardware, including file system drivers, video drivers, network drivers, sound drivers and the camera driver and the like.

Enable ELRepo Warehouse:

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

4.2 View system kernel packages are available:
you can see, only two versions 4.4 and 4.15 can be used:

# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
Loaded plugins: fastestmirror, langpacks
elrepo-kernel                                                   | 2.9 kB  00:00:00     
elrepo-kernel/primary_db                                        | 1.7 MB  00:00:02     
Determining fastest mirrors
* elrepo-kernel: elrepo.org
Available Packages
kernel-lt.x86_64                           4.4.118-1.el7.elrepo            elrepo-kernel
kernel-lt-devel.x86_64                     4.4.118-1.el7.elrepo            elrepo-kernel
kernel-lt-doc.noarch                       4.4.118-1.el7.elrepo            elrepo-kernel
kernel-lt-headers.x86_64                   4.4.118-1.el7.elrepo            elrepo-kernel
kernel-lt-tools.x86_64                     4.4.118-1.el7.elrepo            elrepo-kernel
kernel-lt-tools-libs.x86_64                4.4.118-1.el7.elrepo            elrepo-kernel
kernel-lt-tools-libs-devel.x86_64          4.4.118-1.el7.elrepo            elrepo-kernel
kernel-ml.x86_64                           4.15.6-1.el7.elrepo             elrepo-kernel
kernel-ml-devel.x86_64                     4.15.6-1.el7.elrepo             elrepo-kernel
kernel-ml-doc.noarch                       4.15.6-1.el7.elrepo             elrepo-kernel
kernel-ml-headers.x86_64                   4.15.6-1.el7.elrepo             elrepo-kernel
kernel-ml-tools.x86_64                     4.15.6-1.el7.elrepo             elrepo-kernel
-ml-Tools-Kernel libs.x86_64 4.15.6-1.el7.elrepo ELRepo-Kernel
Kernel-ml-Tools-libs-devel.x86_64 4.15.6-1.el7.elrepo ELRepo-Kernel
perf.x86_64 4.15.6 ELRepo-kernel -1.el7.elrepo
Python-perf.x86_64                   

4.3 to install the latest kernel:
# yum install --enablerepo = ELRepo kernel kernel-ml-
1
--enablerepo option is turned on CentOS designated warehouse system. It is enabled by default elrepo, replaced with elrepo-kernel here.

5. Set grub2
after a good kernel is installed, you need to take after the default boot option and restart to take effect

5.1 can be viewed on the system all the kernel:
# the sudo awk -F \ ''. 1 == $ "menuentry" I ++ {Print ":" $ 2} '/etc/grub2.cfg
0: the CentOS the Linux (4.15.6-1.el7 .elrepo.x86_64). 7 (Core)
. 1: the CentOS the Linux (3.10.0-514.26.2.el7.x86_64). 7 (Core)
2: the CentOS the Linux (3.10.0-327.el7.x86_64). 7 (Core)
. 3 : CentOS Linux (0-Rescue-f9d400c5e1e8c3a8209e990d887d4ac1) 7 (core)

5.2 set grub2
exist on my machine four cores (Tencent cloud machine, do not know why two behind), we want to use this version 4.15, you can grub2-set-default 0 or edit command / etc / default / grub file set.

1. grub2-set-default 0 command set:
wherein 0 awk command from the previous step:

SET-default-grub2 the sudo 0
. 1
2. Edit / etc / default / grub file
set GRUB_DEFAULT = 0, represents a step number on the awk command is displayed as the default kernel core 0:

# vi /etc/default/grub

> GRUB_TIMEOUT. 5 =
> GRUB_DISTRIBUTOR = "$ (Sed 'S, Release. * $ ,, G' / etc /-Release System)"
> = 0 GRUB_DEFAULT
> = GRUB_DISABLE_SUBMENU to true
> = GRUB_TERMINAL_OUTPUT "Console"
> GRUB_CMDLINE_LINUX = "crashkernel = Console Console = ttyS0 = Auto panic, tty0. 5 = "
> = GRUB_DISABLE_RECOVERY" to true "
> GRUB_TERMINAL =" Serial Console "
> GRUB_TERMINAL_OUTPUT =" Serial Console "
> GRUB_SERIAL_COMMAND =" 9600 Serial --speed --unit = = = 0 --word --stop --parity = NO =. 8. 1 "

5.3 configuration file and restart generating grub
Next, create the profile by grub2 gurb2-mkconfig command, and then restart:

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

5.4 verified
by uname -r view can be found already in effect.

Uname -r #
4.15.6-1.el7.elrepo.x86_64

6. remove the old kernel (optional)
kernel, there are two ways to delete: through yum remove command or by yum-utils tools.

6.1 through yum remove command
to view the system in all of the kernel:

RPM -qa # | grep Kernel
Kernel-Tools-libs-3.10.0-514.26.2.el7.x86_64
Kernel-ml-4.15.6-1.el7.elrepo.x86_64
Kernel-3.10.0-327.el7.x86_64
Tools-3.10.0-514.26.2.el7.x86_64-kernel
kernel-headers-3.10.0-514.26.2.el7.x86_64
kernel-3.10.0-514.26.2.el7.x86_64

delete the old kernel RPM package

yum remove kernel-tools-libs-3.10.0-514.26.2.el7.x86_64 kernel-3.10.0-327.el7.x86_64 kernel-tools-3.10.0-514.26.2.el7.x86_64 kernel-headers-3.10.0-514.26.2.el7.x86_64 kernel-3.10.0-514.26.2.el7.x86_64


6.2 via yum-utils tool
if installed kernel no more than three, yum-utils will not remove any of them. Only when you install kernel is greater than three, it will automatically delete old kernel.

6.2.1 install
yum install yum-utils

6.2.2 delete
package-cleanup --oldkernels

Guess you like

Origin blog.csdn.net/kingdelee/article/details/83451573