云计算、AI、云原生、大数据等一站式技术学习平台

网站首页 > 教程文章 正文

Centos 7升级内核版本(centos7.8升级内核)

jxf315 2025-07-02 21:43:09 教程文章 2 ℃

经常在网上看见说升级内核版本直接用yum updata这个命令,但是这个命令不止会升级内核版本还会升级软件的版本,在生产环境还是慎用这个命令。

查看当前内核版本

[root@localhost ~]# uname -r
3.10.0-957.el7.x86_64
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (Core)

启用elrepo仓库

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org #导入ELRepo仓库的公共密钥
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm #安装ELRepo仓库的yum源


升级内核

安装最新版本的内核

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

查看系统上所有可用内核

awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg


系统内有4个内核,我们要使用刚安装的5.13.7,可用通过grub2-set-default 0 命令或编辑 /etc/default/grub 文件来设置

1.通过grub2-set-default 0设置

0是上面查询出来的可用内核

2.编辑/etc/default/grub文件

设置GRUB_DEFAULT=0


grub2-mkconfig -o /boot/grub2/grub.cfg #生成grub配置文件

然后重启电脑,会发现内核版本已经升级成功了


删除旧内核

rpm -qa | grep kernel


可用使用yum remove来删除对应的rpm包

最近发表
标签列表