Migrating Off CentOS 7 and 8: CentOS Stream, AlmaLinux and Upgrade Paths

Migrating Off CentOS 7 and 8: CentOS Stream, AlmaLinux and Upgrade Paths

Reading time1 min
#Linux#CentOS#CentOSStream#AlmaLinux#Migration#Sysadmin

Migrating Off CentOS 7 and 8: CentOS Stream, AlmaLinux and Upgrade Paths

CentOS Linux no longer exists as a supported product. If you still run it, every option below is about getting off it, not about keeping it alive.

ReleaseEnd of life
CentOS Linux 8December 31, 2021
CentOS Stream 8May 31, 2024
CentOS Linux 7June 30, 2024
CentOS Stream 9expected around May 2027, with the end of RHEL 9 full support
CentOS Stream 10current, released December 2024

After end of life, the repositories were removed from mirror.centos.org and the mirror network. Packages for 7, 8 and Stream 8 survive only in the read-only archive at vault.centos.org, which receives no fixes.

CentOS Stream is not the old CentOS

CentOS Linux was a rebuild of RHEL: same packages, released after RHEL. CentOS Stream is the reverse. It is the development branch that the next RHEL minor release is built from, updated continuously. It is stable enough for many workloads and useful for testing against upcoming RHEL changes, but it is not a point-release distribution and its lifecycle is about five years, not ten.

If what you wanted from CentOS was a free, binary-compatible RHEL, the replacements are AlmaLinux and Rocky Linux. RHEL itself is free for up to 16 systems with the Red Hat Developer Subscription for Individuals.

First: make dnf or yum work again

On an EOL system, any package operation fails. On CentOS 8 you see:

Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

On CentOS 7, yum fails trying to reach mirrorlist.centos.org. Every migration tool needs working repositories first, so point them at the vault. Back up the repo files, then:

sudo cp -a /etc/yum.repos.d /root/yum.repos.d.bak
sudo sed -i -e 's|^mirrorlist=|#mirrorlist=|' \
  -e 's|^#baseurl=http://mirror.centos.org|baseurl=https://vault.centos.org|' \
  /etc/yum.repos.d/CentOS-*.repo
sudo yum clean all && sudo yum makecache

The same command works on CentOS 7, CentOS 8 and CentOS Stream 8 repo files. Update to the final packages with sudo yum update (or dnf upgrade) and reboot before any migration. This makes the tools work. It does not make the system secure: the vault has no updates after the EOL date.

Option 1: reinstall (usually the right answer)

Install AlmaLinux, Rocky Linux, RHEL or CentOS Stream on a new machine or VM, move the application and data, switch DNS or the load balancer, and retire the old box. It costs more up front and much less later. In-place upgrades across major versions carry over years of hand-made changes and leftovers, and the old server stays available as a fallback until you are sure.

If you are going this route, write the new server's configuration in Ansible or a similar tool while you are at it.

Option 2: CentOS Linux 8 to AlmaLinux 8 or Rocky Linux 8

Same major version, so this is a conversion, not an upgrade: packages are swapped for the rebuild's equivalents. AlmaLinux 8 and Rocky Linux 8 are supported until 2029.

# AlmaLinux (supports CentOS 8.4 and later; -f helps with the dead CentOS 8 mirrors)
curl -O https://raw.githubusercontent.com/AlmaLinux/almalinux-deploy/master/almalinux-deploy.sh
sudo bash almalinux-deploy.sh

# or Rocky Linux
curl -O https://raw.githubusercontent.com/rocky-linux/rocky-tools/main/migrate2rocky/migrate2rocky.sh
sudo bash migrate2rocky.sh -r

Run either from a console, or inside screen or tmux if you only have SSH, and take a snapshot first. The AlmaLinux script also converts CentOS Stream 8 with -d (an explicit downgrade to the stable release). Verify the result with cat /etc/os-release after a reboot.

Option 3: CentOS Linux 8 to CentOS Stream 8

This was the official path that the CentOS project offered in 2021. It still works with the vault, but CentOS Stream 8 is itself end of life, so it only makes sense as a step toward CentOS Stream 9 (Option 5). After fixing the repos as above:

sudo dnf --disablerepo '*' --enablerepo extras swap centos-linux-repos centos-stream-repos
# the new CentOS-Stream-*.repo files point to dead mirrors again: rerun the vault sed command
sudo dnf distro-sync
sudo reboot
cat /etc/centos-release         # CentOS Stream release 8

distro-sync aligns every package with the Stream repository, including downgrades where needed. Expect a large transaction.

Option 4: CentOS 7 to an EL 8 system

There was never a supported in-place upgrade from CentOS 7 to CentOS 8. The practical tool today is ELevate, the AlmaLinux project's build of Red Hat's Leapp upgrade framework. It supports CentOS 7 to AlmaLinux 8. Rocky Linux targets are no longer supported by ELevate, and Oracle provides its own Leapp for Oracle Linux.

# repos: either the vault sed above, or AlmaLinux's CentOS 7 mirror
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://el7.repo.almalinux.org/centos/CentOS-Base.repo
sudo yum update -y && sudo reboot

sudo yum install -y http://repo.almalinux.org/elevate/elevate-release-latest-el$(rpm --eval %rhel).noarch.rpm
sudo yum install -y leapp-upgrade leapp-data-almalinux
sudo leapp preupgrade

preupgrade changes nothing. It writes a report to /var/log/leapp/leapp-report.txt and lists inhibitors that block the upgrade. Typical ones on CentOS 7 are the pata_acpi kernel module, the PermitRootLogin default changing in OpenSSH, and the removed pam_pkcs11 module. The report gives the fix for each, often a leapp answer command. Fix them, run preupgrade again until it is clean, then:

sudo leapp upgrade
sudo reboot     # the upgrade itself runs in a special boot entry; let it finish

Afterward, check for leftover el7 packages with rpm -qa | grep el7 and review /var/log/leapp/ for warnings. Between 7 and 8, Python 3 replaces Python 2 as the default, iptables moves to the nftables backend, the old network-scripts are deprecated and most PHP and database versions change, so test applications carefully.

Red Hat's own route is convert2rhel to RHEL 7 followed by Leapp to RHEL 8 and 9. It needs a RHEL subscription.

Option 5: from EL 8 (including CentOS Stream 8) to EL 9

ELevate also handles 8 to 9. Its documented sources include AlmaLinux 8 and CentOS Stream 8. The leapp-data package picks the target: leapp-data-almalinux for AlmaLinux 9, leapp-data-centos for CentOS Stream 9.

sudo dnf install -y http://repo.almalinux.org/elevate/elevate-release-latest-el$(rpm --eval %rhel).noarch.rpm
sudo dnf install -y leapp-upgrade leapp-data-almalinux     # or leapp-data-centos
sudo leapp preupgrade
# fix inhibitors from /var/log/leapp/leapp-report.txt
sudo leapp upgrade
sudo reboot

Going from CentOS 7 to a current system this way is three upgrades (7 to 8, 8 to 9, optionally 9 to 10), each with its own inhibitors and application changes. Compare that honestly with a reinstall.

A note on version 10: RHEL 10, CentOS Stream 10 and the standard AlmaLinux 10 build require x86-64-v3 CPUs. Check older hardware before planning an upgrade to 10. AlmaLinux also ships an x86-64-v2 build.

Before any in-place migration

  • Snapshot or full backup, tested.
  • Console access (IPMI, iDRAC, hypervisor or cloud serial console), not only SSH.
  • Third-party repos (EPEL, Docker, database vendors) disabled, then re-added for the new major version afterward.
  • A list of what the server runs, so you know what to test.
  • A clone to rehearse on, if at all possible.

Quick reference

cat /etc/os-release                                    # what you are running
# point dead CentOS repos at the vault
sudo sed -i -e 's|^mirrorlist=|#mirrorlist=|' \
  -e 's|^#baseurl=http://mirror.centos.org|baseurl=https://vault.centos.org|' \
  /etc/yum.repos.d/CentOS-*.repo
sudo bash almalinux-deploy.sh                          # CentOS 8 -> AlmaLinux 8
sudo bash migrate2rocky.sh -r                          # CentOS 8 -> Rocky Linux 8
sudo dnf --disablerepo '*' --enablerepo extras swap centos-linux-repos centos-stream-repos
sudo dnf distro-sync                                   # CentOS 8 -> Stream 8
sudo yum install -y leapp-upgrade leapp-data-almalinux # ELevate: 7 -> 8, 8 -> 9
sudo leapp preupgrade && sudo leapp upgrade