Menu Close

centos内核更新与升级

1:内核更新

# 查看当前kernel版本

[root@localhost ~]# uname -r

# 查看可升级的内核版本

[root@localhost ~]# yum list kernel

# 可选择升级内核版本yum update kernel

# 为了让新安装的内核成为默认启动选项,需要修改GRUB配置。

[root@localhost ~]# vim /etc/default/grub

#修改后文件内容如下:(修改为GRUB_DEFAULT=0,意思是GRUB初始化页面的第一个内核做为默认内核。)

# 执行命令:grub2-mkconfig -o /boot/grub2/grub.cfg

[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg

2:内核升级

# CentOS 允许使用 ELRepo,这是一个第三方仓库,可以将内核升级到最新版本。

# 在CentOS 7上启用 ELRepo 仓库,运行如下命令:

# 导入该源的秘钥

[root@localhost ~]# rpm –import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

# 启用该源仓库

[root@localhost ~]# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm

# 查看有哪些内核版本可供安装

[root@localhost ~]# yum –disablerepo=”*” –enablerepo=”elrepo-kernel” list available

# 安装长期稳定版本,5.4.241-1.el7.elrepo

[root@localhost ~]# yum –enablerepo=elrepo-kernel install kernel-lt -y

# 执行命令:grub2-mkconfig -o /boot/grub2/grub.cfg (已经可以看见5.4.241-1.el7.elrepo的内核了)

[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg

# 重启主机可以看到已经有好几个内核可供启动了,默认第一个内核版本启动。

# 进入系统后查看内核版本。

切换repo源(可选操作)

# 备份

[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

# 下载新的CentOS-Base.repo到/etc/yum.repos.d/

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

# 运行yum makecache生成缓存

[root@localhost ~]# yum makecache

无觅评论,优化体验,加强品牌价值