Guides 11792 Published by

The guide explains how to shift a running CentOS 8 server into the new Rocky Linux environment without reinstalling anything, keeping all data intact. It walks you through backing up with rsync, creating a live‑USB, swapping out CentOS repositories for Rocky’s, and then syncing packages via distro‑sync while preserving configuration files. Along the way it cautions to double‑check device names, clean old repositories, and verify critical services after the transition, offering rollback tips if needed. The final message leaves you ready to reboot into a stable Rocky system with confidence and a sense of accomplishment.



Migrating From CentOS 8 to Rocky Linux—A Straight‑Ahead Playbook

You’ll learn how to move your existing CentOS 8 box into the new Rocky Linux ecosystem without losing data or having to rebuild services from scratch. No fancy scripts, just a few hands‑on steps that keep the core system intact and let you enjoy Rocky’s upstream‑compatible packages.

1 – Back It All Up

Why bother? A full backup is your safety net; you’ll need it if something goes wrong or if you decide to roll back. I’ve seen servers get stuck after a bad update that broke the init system, so start by:

sudo rsync -avxHAX / /mnt/backup/

rsync keeps ownership and permissions intact; add --delete only when you’re sure you want to mirror everything.

2 – Create a Live‑USB of the Latest Rocky

Download the ISO from the official site and write it to a USB stick with:

sudo dd if=Rocky-8.6-x86_64-dvd1.iso of=/dev/sdX bs=4M status=progress && sync

Replace /dev/sdX with your real device; double‑check before running dd.

3 – Boot Into the Live Environment

Power on, hit F12 (or whatever key your BIOS uses) and boot from USB. Pick “Install Rocky Linux” but don’t proceed to install yet.

4 – Replace CentOS Packages With Rocky Repositories

Mount your original root partition:

sudo mount /dev/mapper/centos8-root /mnt/oldroot

Enter a chroot so you’re running commands in the old system’s context:

sudo chroot /mnt/oldroot

Now swap out CentOS repositories for Rocky:

1. Remove existing repo files:

   rm -f /etc/yum.repos.d/*.repo

2. Install the Rocky repos package:

   dnf install https://dl.rockylinux.org/pub/rocky/rhel-8/x86_64/os/Packages/r/rpm-macros-4.14-2.el8.noarch.rpm

3. Import Rocky GPG keys and enable the repos by adding a new file:

   cat > /etc/yum.repos.d/rocky.repo <<EOF
   [AppStream]
   name=Rocky Linux 8 AppStream
   baseurl=https://dl.rockylinux.org/pub/rocky/rhel-8/AppStream/x86_64/os/
   enabled=1
   gpgcheck=1

   [BaseOS]
   name=Rocky Linux 8 BaseOS
   baseurl=https://dl.rockylinux.org/pub/rocky/rhel-8/BaseOS/x86_64/os/
   enabled=1
   gpgcheck=1
   EOF

The reason for this repo swap is that Rocky’s packages are binary‑compatible with CentOS, so you’ll preserve all installed software.

5 – Clean Old Packages and Reinstall

Exit chroot (exit), unmount the old root, then boot from the live USB again. This time choose “Rescue a broken system” to drop into a minimal shell:

chroot /mnt/oldroot
dnf clean all
dnf distro-sync

distro‑sync pulls in the Rocky versions of every package that already exists, updating libraries and binaries while keeping configuration files. If you’ve got custom packages from third‑party repos, double‑check they’re still enabled or add them back.

6 – Verify System Integrity

Back into your regular shell:

cat /etc/os-release | grep PRETTY_NAME

You should see “Rocky Linux 8.x”. Next, check that critical services are running:

systemctl list-units --type=service | grep -E 'httpd|sshd|firewalld'

If any of them are failed, read their logs with journalctl -u <service>. I’ve seen the Apache service fail after a mismatched module version—just reinstall the module package.

7 – Remove CentOS‑Specific Tools

CentOS shipped some legacy utilities (like yum wrapper scripts) that Rocky no longer needs. Clean them up to avoid confusion:

dnf remove yum*

You’ll keep dnf, which is now the default.

8 – Reboot Into Rocky

Remove the USB, let the system boot from disk. If everything boots and your services are healthy, you’re done. If not, roll back using your backup or the last known good snapshot (if you use LVM snapshots).

That’s it—no full reinstall required, just a repository swap, a distro‑sync, and a sanity check.