从 Centos 7 升级到 Centos Stream 8[抄]

Jul 22, 2024

安装epel-relase、yum-utils和rpmconf

yum install yum-utils epel-release -y
yum install rpmconf -y

安装前检查

rpmconf -a
package-cleanup --leaves
package-cleanup --orphans

安装dnf 并执行更新

yum install dnf -y
dnf remove yum yum-metadata-parser -y && rm -rf /etc/yum
dnf upgrade -y
dnf upgrade https://mirrors.bfsu.edu.cn/centos-vault/8.0.1905/BaseOS/x86_64/os/Packages/centos-release-8.0-0.1905.0.9.el8.x86_64.rpm -y
dnf upgrade https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y

删除无用文件、CentOS 7的内核、更换Vault源和移除无法升级的包并安装CentOS 8的内核

dnf clean all
rpm -e `rpm -q kernel`
rpm -e --nodeps sysvinit-tools
minorver=8.0.1905
sudo sed -e "s|^mirrorlist=|#mirrorlist=|g" \
         -e "s|^#baseurl=http://mirror.centos.org/\$contentdir/\$releasever|baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/$minorver|g" \
         -i.bak \
         /etc/yum.repos.d/CentOS-*.repo
dnf remove python36-rpmconf -y
dnf --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync -y
dnf groupupdate "Core" "Minimal Install" -y

升级到Centos Stream 8

dnf install \
    http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/centos-stream-repos-8-4.el8.noarch.rpm \
    http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/centos-stream-release-8.6-1.el8.noarch.rpm \
    http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/centos-gpg-keys-8-4.el8.noarch.rpm \
    -y
dnf distro-sync --allowerasing -y

重启完成升级
注意网络配置可能发生变化,建议重启前先检查

看了哈多个,就这个正常.记录一下

#https://shkong.cc/28.html