Operations 8 min read

How to Migrate from CentOS 7 to AlmaLinux 8 and AlmaLinux 9: A Step‑by‑Step Guide

After CentOS 7 reaches end‑of‑life on June 30 2024, this guide explains why you must migrate, outlines three essential pre‑migration preparations, and provides detailed step‑by‑step commands to upgrade first to AlmaLinux 8 and then to AlmaLinux 9, including post‑migration checks and common pitfalls.

IT Xianyu
IT Xianyu
IT Xianyu
How to Migrate from CentOS 7 to AlmaLinux 8 and AlmaLinux 9: A Step‑by‑Step Guide

CentOS 7 will stop receiving security updates after June 30 2024, leaving servers vulnerable. The official CentOS Stream is a testing branch and not suitable for production, so staying on CentOS 7 is equivalent to running an unpatched system.

Why you must abandon CentOS

CentOS 8 was retired at the end of 2021, and CentOS 7 is the last long‑term support release that is now discontinued. The recommended replacement, CentOS Stream, is unstable for enterprise use. In short: not migrating means running without security patches.

Preparation before migration (three essential tasks)

1. Backup everything – back up system configuration ( /etc ), user data ( /home ), installed package list ( sudo rpm -qa > installed_packages.txt ), and databases (MySQL, PostgreSQL, etc.). A simple tar command can pack the key directories:

sudo tar -czvf backup.tar.gz /etc /home /var/lib/mysql

2. Check hardware and software compatibility – ensure at least 20 GB of free disk space and verify that packages installed on CentOS 7 are compatible with AlmaLinux 8/9.

3. Temporarily disable security services – turn off SELinux and the firewall to avoid interruptions during the upgrade:

sudo setenforce 0          # temporarily disable SELinux
sudo systemctl stop firewalld  # stop firewall

Migration Phase 1: CentOS 7 → AlmaLinux 8

Step 1: Update the current system

sudo yum clean all
sudo yum update -y
sudo reboot

Step 2: Install the migration tool “Leapp” (Elevate)

sudo yum install -y http://repo.almalinux.org/elevate/elevate-release-latest-el7.noarch.rpm

Step 3: Pre‑upgrade check

sudo leapp pre-upgrade   # scans for potential issues

Address any reported problems, such as multiple kernels (remove extras with sudo rpm -e ) or old driver conflicts.

Step 4: Perform the upgrade

sudo leapp upgrade   # starts the migration, will reboot twice automatically

Step 5: Verify the upgrade

cat /etc/os-release   # should show AlmaLinux 8

Clean residual CentOS packages and caches:

sudo yum clean all
sudo rm -rf /var/cache/yum

Migration Phase 2: AlmaLinux 8 → AlmaLinux 9

Step 1: Update AlmaLinux 8

sudo dnf clean all
sudo dnf update -y
sudo reboot

Step 2: Install the ELevate tool (still required)

sudo dnf install -y alinux-elevate-release
sudo dnf install -y elevate-upgrade

Step 3: Pre‑check and upgrade

sudo elevate-upgrade pre-upgrade   # checks for issues
sudo elevate-upgrade upgrade       # performs the upgrade

Again, the system will reboot automatically.

Step 4: Post‑upgrade cleanup

sudo dnf clean all
sudo systemctl enable --now firewalld   # re‑enable firewall
sudo setenforce 1                      # re‑enable SELinux

After migration – five essential tasks

Check service status: systemctl list-units --type=service

Update software repositories – replace old CentOS repos with AlmaLinux repos.

Re‑compile or reinstall kernel modules (e.g., NVIDIA drivers) if needed.

Restore backed‑up data: tar -xzvf backup.tar.gz -C /

Monitor system logs for errors: journalctl -xe

Common pitfalls

Power or network loss during migration – always use a wired connection and UPS.

Leaving multiple old kernels installed – keep only one and remove the rest with sudo rpm -e .

Forgetting to disable SELinux – see the commands in the preparation section.

Software incompatibility after upgrade – downgrade problematic packages with dnf downgrade or contact the vendor.

Final reminder

If this is your first migration, practice on a virtual machine (VirtualBox or VMware) before touching production servers. AlmaLinux offers long‑term support and a vibrant community, making it a stable foundation for future workloads.

FirewallCentOSSELinuxAlmaLinuxLeappLinux migrationsystem backup
IT Xianyu
Written by

IT Xianyu

We share common IT technologies (Java, Web, SQL, etc.) and practical applications of emerging software development techniques. New articles are posted daily. Follow IT Xianyu to stay ahead in tech. The IT Xianyu series is being regularly updated.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.