首页 > 系统相关 >centos 升级内核 和版本

centos 升级内核 和版本

时间:2022-10-27 13:35:43浏览次数:36  
标签:CentOS x86 centos elrepo 64 内核 版本 yum el7

# uname -sr 查看当前的kernel版本

Linux 3.10.0-693.el7.x86_64

 

我使用的操作系统是Centos7,默认的内核版本是3.10.0,当前最新的内核版本是5.12以上。升级内核的方法有多种。在这里介绍一种比较简便的方法。
依次运行以下命令:

#导入ELRepo仓库的公钥
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
#为yum安装ELRepo仓库
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
#查看可用版本
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
#安装最新内核
yum --enablerepo=elrepo-kernel install kernel-ml

# 查看当前可用内核
sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg

[root@localhost ~]# sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
0 : CentOS Linux (3.10.0-1160.76.1.el7.x86_64) 7 (Core)
1 : CentOS Linux (6.0.5-1.el7.elrepo.x86_64) 7 (Core)
2 : CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
3 : CentOS Linux (0-rescue-adf2d972f04c408b890f10e6bf63cf16) 7 (Core)

上图为执行上一条命令的示例,根据计算机的实际响应,查看最新内核前的序号,然后执行命令grub2-set-default ${序号} ,例如:grub2-set-default 0

升级完成,可以通过uname -r命令进项验证。


[root@localhost ~]# grub2-set-default 1
[root@localhost ~]# uname -r
6.0.5-1.el7.elrepo.x86_64


mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

yum clean all
yum makecache

yum update

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

 

标签:CentOS,x86,centos,elrepo,64,内核,版本,yum,el7
From: https://www.cnblogs.com/fenghua001/p/16831890.html

相关文章