CentOS 7 & 8 migration to Rocky Linux 8.5

Wed, Jan 12, 2022 2-minute read

I have used CentOS 7 for a while on my local servers at home and when CentOS 8 came out I started installing that as a replacement.

When Redhat announced that they would change CentOS into something else not as stable, I started considering going to Debian or Ubuntu.

Luckily Rocky Linux came to the rescue, so I have made this little migration guide for myself, so I can remember how to migrate either a CentOS 7 or 8 installation to Rocky Linux 8.5.

The guide for upgrading CentoOS 7 -> Rocky Linux 8.5 involves first upgrading to CentOS 8 and then upgrade to RockOS from there.

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

rpmconf will ask you questions about what to do - just tell it N, which means keep.

sudo -E rpmconf -a
sudo -E yum install dnf
sudo -E dnf -y remove yum yum-metadata-parser
sudo -E rm -Rf /etc/yum
sudo -E dnf upgrade
sudo -E dnf install http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/{centos-linux-repos-8-3.el8.noarch.rpm,centos-linux-release-8.5-1.2111.el8.noarch.rpm,centos-gpg-keys-8-3.el8.noarch.rpm}
sudo -E dnf -y upgrade https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo -E dnf clean all
sudo -E rpm -e `rpm -q kernel`
sudo -E rpm -e --nodeps sysvinit-tools
sudo -E dnf remove dracut-network rpmconf
sudo -E dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
sudo -E dnf -y install kernel-core
sudo -E dnf -y groupupdate "Core"

Reboot and verify that your services still start as expected and you can do a

cat /etc/*release

And you should get an output similar to

CentOS Linux release 8.5.2111
NAME="CentOS Linux"
ID_LIKE="rhel fedora"
PRETTY_NAME="CentOS Linux 8"
CentOS Linux release 8.5.2111
CentOS Linux release 8.5.2111

When you are happy with the current state of CentOS8, then its time to follow the guide for upgrading CentOS 8 to Rocky Linux, which is extremly simple:

curl https://raw.githubusercontent.com/rocky-linux/rocky-tools/main/migrate2rocky/migrate2rocky.sh -o migrate2rocky.sh
chmod a+x migrate2rocky.sh
sudo -E ./migrate2rocky.sh -r

When you run the script it will output a lot of information while it changes the stream from Centos8 to Rocky Linux, and then finally upgrade all packages.

When everything is done, you just have to reboot - and voila, you are running Rocky Linux.