CentOS Stream 8升级到最新版的操作步骤
升级前务必备份系统关键数据(如/home、/etc、/var等目录),避免因升级异常导致数据丢失。
执行以下命令确认当前系统版本,确保为CentOS Stream 8:
cat /etc/redhat-release
# 或
cat /etc/centos-release
将CentOS Stream 8的现有软件包更新至最新版本,避免升级时出现兼容性问题:
sudo dnf update -y
通过官方仓库安装CentOS Stream 8的软件源,确保后续升级来源可靠:
sudo dnf install centos-release-stream -y
使用dnf swap命令替换CentOS Linux仓库为CentOS Stream仓库,并同步系统版本:
sudo dnf swap centos-{linux,stream}-repos -y
sudo dnf distro-sync -y
过程中可能会提示确认软件包升级/降级,根据需求选择即可。
升级完成后,检查系统版本是否符合预期(应为CentOS Stream 8的最新版本,如8.x):
cat /etc/redhat-release
重启系统使升级后的配置和软件包生效:
sudo reboot
sudo dnf clean all清理缓存后重新执行distro-sync。