centos7升级到centos8
只负责记录, 升级出了问题责任自负.
#更换 centos7 vault源
mirrors=http://ftp.iij.ad.jp/pub/linux/centos-vault/7.9.2009/
sed -e "s|^mirrorlist=|#mirrorlist=|g" -e "s|#baseurl=http://mirror.centos.org/centos/\$releasever/|baseurl=$mirrors|" \
-i.bak /etc/yum.repos.d/CentOS-*.repo
yum -y install epel-release dnf
dnf upgrade -y
#开始升级 Centos8
dnf install -y http://mirrors.klayer.com/centos-vault/8.5.2111//BaseOS/x86_64/os/Packages/{centos-linux-release-8.5-1.2111.el8.noarch.rpm,centos-gpg-keys-8-3.el8.noarch.rpm,centos-linux-repos-8-3.el8.noarch.rpm}
minorver=8.5.2111
#mirrors=https://mirrors.aliyun.com/centos-vault
mirrors=http://ftp.iij.ad.jp/pub/linux/centos-vault
sudo sed -e "s|^mirrorlist=|#mirrorlist=|g" \
-e "s|^#baseurl=http://mirror.centos.org/\$contentdir/\$releasever|baseurl=$mirrors/$minorver|g" \
-i.bak \
/etc/yum.repos.d/CentOS-*.repo
dnf -y remove NetworkManager dracut-network python36-rpmconf fail2ban* yum yum-metadata-parser libsysfs
rm -rf /etc/yum
dnf upgrade -y epel-release
dnf clean all
rpm -e `rpm -q kernel`
rpm -e --nodeps sysvinit-tools
dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
dnf -y install kernel-core
dnf -y groupupdate Core "Minimal Install"
rpm -qa | grep '\.el7' | xargs xargs rpm -e # 卸载
cat /etc/redhat-release
Error: transaction check vs depsolve: (gcc >= 8 with gcc < 9) is needed by annobin-9.72-1.el8_5.2.x86_64
如果遇上需要annobin包报错, 用 rpm 强制安装一下
rpm -ivh --nodeps --force `find /var/cache/dnf -name annobin*`
这几个包也可以删除
dnf -y remove NetworkManager dracut-network python36-rpmconf
centos8的三个包centos-release centos-gpg-keys centos-repos版本会有变动, 操作的时候需要注意选择更新.
也可以不用http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/ ,选用centos vault的库.
总结
在dnf -y --releasever=8 的时候遇上 rpm 包需要的就用rpm -ivh --nodeps --force强制安装, 其他要不就是rpm -e --nodeps强制卸载一下