CentOS 7.x升级内核

第一种针对当前内核版本的小版本升级可以采用如下方法:

[root@localhost ~]# uname -r
3.10.0-862.el7
[root@localhost ~]# yum list kernel
[root@localhost ~]# yum update -y kernel
[root@localhost ~]# uname -r
3.10.0-862.14.4.el7
[root@localhost ~]# grub2-editenv list
saved_entry=CentOS Linux (3.10.0-862.14.4.el7.x86_64) 7 (Core)  #升级完成小版本之后,系统会将升级后的小版本内核设置为默认启动内核
#执行完上述命令之后,使用uname -r对比可以看出已经升级了小版本
[root@localhost ~]# yum list kernel 
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.sjtu.edu.cn
 * elrepo: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.shu.edu.cn
 * updates: ftp.sjtu.edu.cn
elrepo                                                      | 2.9 kB  00:00:00     
elrepo/primary_db                                           | 489 kB  00:00:06     
Installed Packages
kernel.x86_64                     3.10.0-862.el7                          @anaconda
kernel.x86_64                     3.10.0-862.14.4.el7                     @updates 

第二种升级大版本

首先了解下这个网站
https://www.elrepo.org
1.导入公钥
[root@localhost ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
2.安装ELRepo
[root@localhost ~]# rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
3.禁用其他的repo源,启用ELRepo源
[root@localhost ~]# yum --disablerepo=\* --enablerepo=elrepo-kernel repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * elrepo-kernel: mirrors.tuna.tsinghua.edu.cn
repo id       repo name                                                      status
elrepo-kernel ELRepo.org Community Enterprise Linux Kernel Repository - el7  37
repolist: 37
4.查看ELRepo可用的软件包
[root@localhost ~]# yum --disablerepo=\* --enablerepo=elrepo-kernel list kernel*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * elrepo-kernel: mirrors.tuna.tsinghua.edu.cn
Installed Packages
kernel.x86_64                            3.10.0-862.el7              @anaconda     
kernel.x86_64                            3.10.0-862.14.4.el7         @updates      
kernel-ml.x86_64                         4.18.13-1.el7.elrepo        @elrepo-kernel
kernel-tools.x86_64                      3.10.0-862.el7              @anaconda     
kernel-tools-libs.x86_64                 3.10.0-862.el7              @anaconda     
Available Packages
kernel-lt.x86_64                         4.4.160-1.el7.elrepo        elrepo-kernel 
kernel-lt-devel.x86_64                   4.4.160-1.el7.elrepo        elrepo-kernel 
kernel-lt-doc.noarch                     4.4.160-1.el7.elrepo        elrepo-kernel 
kernel-lt-headers.x86_64                 4.4.160-1.el7.elrepo        elrepo-kernel 
kernel-lt-tools.x86_64                   4.4.160-1.el7.elrepo        elrepo-kernel 
kernel-lt-tools-libs.x86_64              4.4.160-1.el7.elrepo        elrepo-kernel 
kernel-lt-tools-libs-devel.x86_64        4.4.160-1.el7.elrepo        elrepo-kernel 
kernel-ml-devel.x86_64                   4.18.13-1.el7.elrepo        elrepo-kernel 
kernel-ml-doc.noarch                     4.18.13-1.el7.elrepo        elrepo-kernel 
kernel-ml-headers.x86_64                 4.18.13-1.el7.elrepo        elrepo-kernel 
kernel-ml-tools.x86_64                   4.18.13-1.el7.elrepo        elrepo-kernel 
kernel-ml-tools-libs.x86_64              4.18.13-1.el7.elrepo        elrepo-kernel 
kernel-ml-tools-libs-devel.x86_64        4.18.13-1.el7.elrepo        elrepo-kernel 
5.安装最新的kernel版本
[root@localhost ~]# yum --disablerepo=\* --enablerepo=elrepo-kernel install kernel-ml.x86_64
6.此时还不能直接安装新版本内核的工具包,需要先卸载旧版本内核的工具包
查看老版本
[root@localhost ~]# yum list installed | grep kernel-tools*
kernel-tools.x86_64                     3.10.0-862.el7                 @anaconda
kernel-tools-libs.x86_64                3.10.0-862.el7                 @anaconda
卸载老版本
[root@localhost ~]# yum remove -y kernel-tools*
7.安装最新版本的内核工具包
[root@localhost ~]# yum --disablerepo=\* --enablerepo=elrepo-kernel install -y kernel-ml-tools.x86_64
到此,内核大版本升级虽然已完成,但是系统当前版本依然是:
[root@localhost ~]# uname -r
3.10.0-862.14.4.el7.x86_64

!注意:重启开机界面,默认的内核版本是之前升级的小版本,并不是大版本号

可以手动选择升级后的大版本号,也可以进入系统修改默认启动内核:

[root@localhost ~]# 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 (4.18.13-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-665da203-11f4-4366-92ce-5021231ee154' {
menuentry 'CentOS Linux (3.10.0-862.14.4.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-665da203-11f4-4366-92ce-5021231ee154' {
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-665da203-11f4-4366-92ce-5021231ee154' {
menuentry 'CentOS Linux (0-rescue-23361e5303e64609b437b298ecde192e) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-23361e5303e64609b437b298ecde192e-advanced-665da203-11f4-4366-92ce-5021231ee154' {
[root@localhost ~]# grub2-set-default 'CentOS Linux (4.18.13-1.el7.elrepo.x86_64) 7 (Core)'
[root@localhost ~]# grub2-editenv list
saved_entry=CentOS Linux (4.18.13-1.el7.elrepo.x86_64) 7 (Core)
重启系统,查看
[root@localhost ~]# uname -r
4.18.13-1.el7.elrepo.x86_64
如果不需要旧版本的内核软件包,可以使用yum卸载掉

第三种升级内核的方式:

了解下这个网站
https://www.kernel.org/
可以在这里下载最新版本的内核tar包,然后确保系统装了gcc,cmake等工具,然后跟其他软件的tar安装方式一样,解压,编译,安装即可。

附:

kernel-ml 中的ml是英文【mainline stable】的缩写,elrepo-kernel中罗列出来的是最新的稳定主线版本。

kernel-lt 中的lt是英文【long term support】的缩写,elrepo-kernel中罗列出来的长期支持版本。
参考原文:https://blog.csdn.net/breeze915/article/details/79243673

 

 

posted on 2018-10-12 14:19  Lucky_7  阅读(545)  评论(0编辑  收藏  举报

导航