**本文使用于小版本内核升级比如从7.4 到7.9,如果是从6.x到7.x最好是先执行预升级命令
来查看有哪些报错,然后一一解决,再升级。
查看操作系统相关信息
[root@localhost yum.repos.d]# uname -a
Linux localhost.localdomain 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
查看当前默认升级到的版本
[root@localhost yum.repos.d]# yum list centos-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.ustc.edu.cn
* epel: mirrors.bfsu.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.ustc.edu.cn
Installed Packages
centos-release.x86_64 7-4.1708.el7.centos @anaconda
Available Packages
centos-release.x86_64 7-9.2009.1.el7.centos updates
You have mail in /var/spool/mail/root
找可用版本
Index of /centos/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
备份所有文件
mkdir -p /etc/yum.repos.d/backup
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/
cp /etc/yum.repos.d/backup/CentOS-Base.repo /etc/yum.repos.d/
替换源路径,备份之前的源配置
这里不采用默认升级到某个版本,指定某个版本升级(小版本7.4 - 7.9),替换版本并备份文件
sed -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|g' 's|$releasever|7.9.2009|g' -i.bak /etc/yum.repos.d/CentOS-*.repo
清除yum本机缓存
若不执行该步骤,即使仓库更新过,但 Yum 可能使用缓存信息,而不会重新同步,导致更新的内核版本有误。
查看仓库信息
更新内核
[root@localhost yum.repos.d]# yum update
...
Replaced:
grub2.x86_64 1:2.02-0.64.el7.centos grub2-tools.x86_64 1:2.02-0.64.el7.centos iwl7265-firmware.noarch 0:22.0.7.0-56.el7
Complete!
You have mail in /var/spool/mail/root
重启
[root@localhost yum.repos.d]# reboot
Connection closing...Socket close.
查看更新
[root@localhost yum.repos.d]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
You have mail in /var/spool/mail/root
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-1160.62.1.el7.x86_64 #1 SMP Tue Apr 5 16:57:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
ks.cfg介绍
ks.cfg说明
https://blog.51cto.com/lustlost/910705
yum自建仓库
https://www.linuxe.cn/post-300.html