一、升级前操作
1. 查看当前内核版本
[root@VM_0_17_centos ~]# uname -r
3.10.0-862.el7.x86_64
2. 安装 ELRepo 源
(1) 导入公共秘钥
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@VM_0_17_centos ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
(2) 安装 ELRepo 的 YUM 源
rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
[root@VM_0_17_centos ~]# rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
Retrieving https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
Preparing... ################################# [100%]
Updating / installing...
1:elrepo-release-7.0-3.el7.elrepo ################################# [100%]
二、安装内核
1. 通过 YUM 安装
yum --enablerepo=elrepo-kernel install kernel-ml-devel kernel-ml
默认安装 mainline 版本(主线版本)。
[root@VM_0_17_centos ~]# yum --enablerepo=elrepo-kernel install kernel-ml-devel kernel-ml
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
* elrepo: mirror-hk.koddos.net
* elrepo-kernel: mirror-hk.koddos.net
elrepo | 2.9 kB 00:00:00
elrepo-kernel | 2.9 kB 00:00:00
(1/2): elrepo/primary_db | 477 kB 00:00:00
(2/2): elrepo-kernel/primary_db | 1.8 MB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package kernel-ml.x86_64 0:5.3.7-1.el7.elrepo will be installed
---> Package kernel-ml-devel.x86_64 0:5.3.7-1.el7.elrepo will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================================================
Installing:
kernel-ml x86_64 5.3.7-1.el7.elrepo elrepo-kernel 48 M
kernel-ml-devel x86_64 5.3.7-1.el7.elrepo elrepo-kernel 13 M
Transaction Summary
=====================================================================================================================================================================
Install 2 Packages
Total download size: 61 M
Installed size: 264 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): kernel-ml-devel-5.3.7-1.el7.elrepo.x86_64.rpm | 13 MB 00:00:16
(2/2): kernel-ml-5.3.7-1.el7.elrepo.x86_64.rpm | 48 MB 00:01:16
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 807 kB/s | 61 MB 00:01:16
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : kernel-ml-5.3.7-1.el7.elrepo.x86_64 1/2
Installing : kernel-ml-devel-5.3.7-1.el7.elrepo.x86_64 2/2
Verifying : kernel-ml-devel-5.3.7-1.el7.elrepo.x86_64 1/2
Verifying : kernel-ml-5.3.7-1.el7.elrepo.x86_64 2/2
Installed:
kernel-ml.x86_64 0:5.3.7-1.el7.elrepo kernel-ml-devel.x86_64 0:5.3.7-1.el7.elrepo
Complete!
2. 查看已安装的内核版本
rpm -qa kernel*
[root@VM_0_17_centos ~]# rpm -qa kernel*
kernel-headers-3.10.0-957.1.3.el7.x86_64
kernel-3.10.0-862.el7.x86_64
kernel-ml-devel-5.3.7-1.el7.elrepo.x86_64
kernel-tools-libs-3.10.0-862.el7.x86_64
kernel-tools-3.10.0-862.el7.x86_64
kernel-devel-3.10.0-862.el7.x86_64
kernel-ml-5.3.7-1.el7.elrepo.x86_64
rpm -qa | grep -i kernel
[root@VM_0_17_centos ~]# rpm -qa | grep -i kernel
kernel-headers-3.10.0-957.1.3.el7.x86_64
kernel-3.10.0-862.el7.x86_64
abrt-addon-kerneloops-2.1.11-50.el7.centos.x86_64
kernel-ml-devel-5.3.7-1.el7.elrepo.x86_64
kernel-tools-libs-3.10.0-862.el7.x86_64
kernel-tools-3.10.0-862.el7.x86_64
kernel-devel-3.10.0-862.el7.x86_64
kernel-ml-5.3.7-1.el7.elrepo.x86_64
3. 查找新安装的内核完整名称
cat /boot/grub2/grub.cfg | grep menuentry
[root@VM_0_17_centos ~]# cat /boot/grub2/grub.cfg | grep menuentry
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
menuentry_id_option=""
export menuentry_id_option
menuentry 'CentOS Linux (5.3.7-1.el7.elrepo.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-862.el7.x86_64-advanced-21dbe030-aa71-4b3a-8610-3b942dd447fa' {
menuentry 'CentOS Linux (3.10.0-862.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-862.el7.x86_64-advanced-21dbe030-aa71-4b3a-8610-3b942dd447fa' {
menuentry 'CentOS Linux (0-rescue-c28d40cbc8e3adcb4e32d9779a77b39e) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-c28d40cbc8e3adcb4e32d9779a77b39e-advanced-21dbe030-aa71-4b3a-8610-3b942dd447fa' {
三、内核切换
1. 更改默认内核
命令2选1:
(1) grub2-set-default 0
默认启动顺序应该为1,升级后内核是往前面插入,为0。
[root@VM_0_17_centos ~]# grub2-set-default 0
(2) grub2-set-default ' '
[root@VM_0_17_centos ~]# grub2-set-default 'CentOS Linux (5.3.7-1.el7.elrepo.x86_64) 7 (Core)'
2. 查看默认启动内核是否更换成功
grub2-editenv list
[root@VM_0_17_centos ~]# grub2-editenv list
saved_entry=CentOS Linux (5.3.7-1.el7.elrepo.x86_64) 7 (Core)
三、激活内核
1. 重启系统
reboot
[root@VM_0_17_centos ~]# reboot
2. 查看内核版本
uname -r
[root@VM_0_17_centos ~]# uname -r
5.3.7-1.el7.elrepo.x86_64