[Centos系统] centos7升级centos8

754 0
Honkers 2025-7-20 08:55:32 | 显示全部楼层 |阅读模式

centos7升级centos8(亲测好用)

#Centos 7 => 8 manual upgrade.
#No support is given, YMMV, remember backups!
#Tested with upcloud and cloudatcost.

Get ready to upgrade

yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install rpmconf yum-utils

Resolve all config stuff.

rpmconf -a

Packages you might not need/require, remove if something doens’t seem to be required.

package-cleanup --leaves
package-cleanup --orphans

Install DNF.

yum -y install dnf

Remove yum

dnf -y remove yum yum-metadata-parser
rm -Rf /etc/yum

Upgrade system to be up-to-date

dnf -y upgrade

Install new versions:

dnf -y upgrade http://mirror.bytemark.co.uk/centos/8/BaseOS/x86_64/os/Packages/centos-release-8.0-0.1905.0.9.el8.x86_64.rpm

Upgrade EPEL

dnf -y upgrade https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Dnf clean

dnf clean all

Remove kernels, kernel packages are kernel-core in c8.

rpm -e 'rpm -q kernel'

Remove definitely conflicting stuff.

rpm -e --nodeps sysvinit-tools

Try to run the upgrade

dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync

If it doesn’t succeed (YMMV), fix dependency stuff by removing/installing conficting stuff and try again.
eg. if you want to drop all the dependencies

#dnf remove python2-six python-six
#eg. you don’t want to drop all the dependencies, they would remove too much.
#rpm -e --nodeps sysvinit-tools

Process new configs

rpmconf -a

Ensure kernel is properly installed

rpm -e kernel-core
dnf -y install kernel-core

Make sure grub is updated (ensure that it’s right place!)

ROOTDEV='ls /dev/*da|head -1';
echo “Detected root as $ROOTDEV…”
grub2-install $ROOTDEV

Install new stuff that is in the Core/Minimum Install:

dnf -y groupupdate “Core” “Minimal Install”

Install back the stuff that you need and removed to get the dnf distro-sync to succeed.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2026 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行