🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now β†’
Menu

Categories

How to Migrate from CentOS to AlmaLinux: Complete Step-by-Step Guide (2026)

How to Migrate from CentOS to AlmaLinux: Complete Step-by-Step Guide (2026)

CentOS as we knew it is dead. Red Hat ended CentOS Linux 8 on December 31, 2021, and CentOS 7 reached end-of-life on June 30, 2024. If you’re still running CentOS, your servers are no longer receiving security patches β€” and that’s a ticking time bomb.

AlmaLinux is the most popular CentOS replacement. It’s 1:1 binary-compatible with RHEL, backed by CloudLinux, and provides 10 years of free support. This guide walks you through the entire migration process, from pre-flight checks to post-migration verification.

Important: CentOS 7 and CentOS 8 are end-of-life. Every day you delay migration is a day your servers are vulnerable to unpatched security exploits. Migrate now.


Migration Paths Overview

Source Target Method Difficulty Downtime
CentOS 8AlmaLinux 8almalinux-deployEasy15-30 min
CentOS Stream 8AlmaLinux 8almalinux-deployEasy15-30 min
AlmaLinux 8AlmaLinux 9ELevate (leapp)Medium30-60 min
CentOS 7AlmaLinux 8 → 9ELevate (two-step)Hard1-2 hours
CentOS 7AlmaLinux 9Fresh install + data migrationMedium2-4 hours

Phase 1: Pre-Migration Checklist

Rule #1: Never migrate a production server without a full backup and a tested rollback plan. Ever.

1.1 Create a Full Backup

# Full system backup
tar czf /backup/full-system-$(date +%Y%m%d).tar.gz \
  --exclude=/proc --exclude=/sys --exclude=/dev \
  --exclude=/run --exclude=/tmp --exclude=/backup /

# Database backups
mysqldump --all-databases > /backup/mysql-all-$(date +%Y%m%d).sql
pg_dumpall > /backup/postgres-all-$(date +%Y%m%d).sql

# List all installed packages (for reference)
rpm -qa --qf "%{NAME}\n" | sort > /backup/installed-packages.txt

# Save current configs
cp -r /etc /backup/etc-backup-$(date +%Y%m%d)

1.2 Check Current System Status

# Check OS version
cat /etc/os-release

# Check kernel
uname -r

# Check disk space (need at least 5GB free)
df -h /

# Check for third-party repos
yum repolist all

# Check for custom kernel modules
lsmod | grep -v "^Module"

# Check SELinux status
getenforce

# Check running services
systemctl list-units --type=service --state=running

1.3 Document Your Environment

Before migrating, document everything:

  • All running services and their configurations
  • Custom firewall rules (firewall-cmd --list-all)
  • Cron jobs (crontab -l for all users)
  • Third-party repositories
  • Custom kernel parameters (/etc/sysctl.conf)
  • SSL certificates and their expiration dates
  • Network configuration (static IPs, bonds, VLANs)

Phase 2: CentOS 8 → AlmaLinux 8 (In-Place Migration)

This is the easiest migration path. The almalinux-deploy script handles everything automatically.

Step 1: Download and Run the Migration Script

# Download the official migration script
curl -O https://raw.githubusercontent.com/AlmaLinux/almalinux-deploy/master/almalinux-deploy.sh

# Make it executable
chmod +x almalinux-deploy.sh

# Run the migration (as root)
sudo bash almalinux-deploy.sh

What the Script Does:

  1. Checks system compatibility and disk space
  2. Removes CentOS-specific packages and GPG keys
  3. Replaces CentOS repositories with AlmaLinux repositories
  4. Installs AlmaLinux release packages
  5. Runs dnf distro-sync to synchronize all packages
  6. Updates GRUB configuration with AlmaLinux branding

Step 2: Reboot and Verify

# Reboot the server
sudo reboot

# After reboot, verify the migration
cat /etc/os-release
# Should show: AlmaLinux 8.x

# Check all packages are from AlmaLinux
rpm -qa --qf "%{NAME} %{VENDOR}\n" | grep -v "AlmaLinux" | grep -v "Red Hat"

# Verify kernel
uname -r

# Check services are running
systemctl --failed

Tip: The migration is reversible before reboot. If anything goes wrong during the script execution, your system remains on CentOS. After reboot with AlmaLinux packages, reverting requires restoring from backup.


Phase 3: AlmaLinux 8 → AlmaLinux 9 (Major Upgrade)

After migrating to AlmaLinux 8, you should upgrade to AlmaLinux 9 for the latest features and longest support (until 2032). AlmaLinux provides the ELevate tool based on Red Hat’s leapp framework.

Step 1: Prepare the System

# Update AlmaLinux 8 fully
sudo dnf update -y
sudo reboot

# Install ELevate packages
sudo dnf install -y http://repo.almalinux.org/elevate/elevate-release-latest-el8.noarch.rpm

# Install the leapp upgrade tool
sudo dnf install -y leapp-upgrade leapp-data-almalinux

Step 2: Run Pre-Upgrade Check

# Run the pre-upgrade assessment
sudo leapp preupgrade

# Review the report
cat /var/log/leapp/leapp-report.txt

# Common inhibitors and fixes:
# 1. Remove pam_pkcs11 module if detected
sudo leapp answer --section remove_pam_pkcs11_module_check.confirm=True

# 2. Remove make-devel if present
sudo dnf remove make-devel -y

# 3. Fix network interface naming
# Check if using old-style names (eth0)
# If so, AlmaLinux 9 uses predictable names (ens33, enp0s3)

Step 3: Run the Upgrade

# Start the upgrade process
sudo leapp upgrade

# This will:
# - Download AlmaLinux 9 packages
# - Create an upgrade initramfs
# - Schedule the upgrade for next boot

# Reboot to perform the upgrade
sudo reboot

# The system will boot into an upgrade environment
# This takes 15-45 minutes depending on packages installed
# DO NOT interrupt this process

Step 4: Post-Upgrade Verification

# Verify AlmaLinux 9
cat /etc/os-release
# NAME="AlmaLinux"
# VERSION="9.x"

# Check kernel version
uname -r
# Should be 5.14.x or newer

# Rebuild the RPM database
sudo rpm --rebuilddb

# Clean up old packages
sudo dnf clean all

# Check for any remaining EL8 packages
rpm -qa | grep el8

# Remove leftover upgrade artifacts
sudo rm -rf /root/tmp_leapp_py3
sudo dnf remove leapp-upgrade-el8toel9 leapp-data-almalinux -y

# Verify all services
systemctl --failed
systemctl list-units --type=service --state=running

Phase 4: CentOS 7 Migration (Special Considerations)

Warning: CentOS 7 has been end-of-life since June 30, 2024. The longer you wait, the more vulnerabilities accumulate. Two migration strategies are available.

Option A: ELevate Two-Step Upgrade (In-Place)

# Step 1: CentOS 7 -> AlmaLinux 8
sudo yum install -y http://repo.almalinux.org/elevate/elevate-release-latest-el7.noarch.rpm
sudo yum install -y leapp-upgrade leapp-data-almalinux
sudo leapp preupgrade
# Fix all inhibitors from the report
sudo leapp upgrade
sudo reboot
# Wait for upgrade to complete

# Step 2: AlmaLinux 8 -> AlmaLinux 9
# Follow Phase 3 above

Option B: Fresh Install + Data Migration (Recommended for CentOS 7)

For CentOS 7 servers, we strongly recommend a fresh AlmaLinux 9 install with data migration. Here’s why:

  • CentOS 7 uses Python 2.7, old OpenSSL, and outdated libraries
  • Two major version jumps (7→8→9) compound risks
  • Fresh install gives you a clean, optimized system
  • Takes about the same time as two-step ELevate
# On the OLD CentOS 7 server: Export data
# -----------------------------------------
# Databases
mysqldump --all-databases --single-transaction > /backup/mysql-all.sql
pg_dumpall > /backup/postgres-all.sql

# Web content
tar czf /backup/www.tar.gz /var/www/

# Configs
tar czf /backup/configs.tar.gz /etc/nginx/ /etc/httpd/ /etc/php* /etc/my.cnf* \
  /etc/postfix/ /etc/ssl/ /etc/letsencrypt/

# Cron jobs
for user in $(cut -f1 -d: /etc/passwd); do
  crontab -l -u $user 2>/dev/null > /backup/cron-$user.txt
done

# User accounts (if needed)
cp /etc/passwd /etc/shadow /etc/group /backup/

# On the NEW AlmaLinux 9 server: Import data
# -------------------------------------------
# Install fresh AlmaLinux 9 (minimal or server)
# Install required services (nginx, php, mysql, etc.)
# Restore databases, web content, configs
# Update config file paths if changed between versions
# Test everything before switching DNS

Post-Migration Checklist

Check Task Command
1Verify OS versioncat /etc/os-release
2Check failed servicessystemctl --failed
3Verify SELinux statusgetenforce
4Check firewall rulesfirewall-cmd --list-all
5Verify web servercurl -I http://localhost
6Test database connectionsmysql -e "SHOW DATABASES;"
7Verify PHP versionphp -v
8Check SSL certificatescertbot certificates
9Verify cron jobscrontab -l
10Check for security updatesdnf check-update --security
11Enable automatic updatesdnf install dnf-automatic
12Monitor logs for errorsjournalctl -p err --since today

Common Pitfalls & Solutions

1. Third-Party Repositories Breaking

Problem: Repos like EPEL, Remi, or PGDG may have incompatible packages after migration.

Solution: Disable all third-party repos before migration. Re-enable the AlmaLinux 9 versions afterward:

dnf install epel-release
dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm

2. PHP Version Changes

Problem: CentOS 7 ships PHP 5.4, AlmaLinux 9 ships PHP 8.0+. Your code may break.

Solution: Test your application with the new PHP version before migration. Use Remi repo for specific PHP versions if needed.

3. MySQL/MariaDB Version Jump

Problem: CentOS 7 uses MariaDB 5.5, AlmaLinux 9 uses MariaDB 10.5+. Schema changes may be needed.

Solution: Dump databases before migration, install the new MariaDB version, then import. Run mysql_upgrade after import.

4. Network Interface Naming

Problem: CentOS 7 may use eth0, while AlmaLinux 9 uses predictable names like ens192 or enp0s3.

Solution: Check your network config after upgrade. Update /etc/sysconfig/network-scripts/ or use nmcli to reconfigure.

5. SELinux Denials After Upgrade

Problem: SELinux contexts may change between major versions, causing denials.

Solution: Relabel the entire filesystem after major upgrade:

sudo touch /.autorelabel
sudo reboot

Why AlmaLinux Over Rocky Linux?

Both AlmaLinux and Rocky Linux are excellent CentOS replacements. Here’s why many choose AlmaLinux:

  • CloudLinux backing β€” 20+ years of enterprise Linux experience, especially in hosting
  • ELevate project β€” Official migration tooling from CentOS/RHEL (Rocky doesn’t offer this)
  • cPanel/WHM support β€” Officially supported by cPanel
  • FIPS 140-3 certification β€” In progress, critical for government/regulated industries
  • Larger community β€” More contributors, faster releases, broader testing
  • Foundation-governed β€” AlmaLinux OS Foundation ensures community ownership

Essential Books for Your Migration:


Further Reading on Dargslan


Final Verdict

CentOS 8 → AlmaLinux 8: Run the almalinux-deploy.sh script. Takes 15-30 minutes with minimal risk. Do it today.

AlmaLinux 8 → AlmaLinux 9: Use ELevate (leapp). Plan a 30-60 minute maintenance window. Test in staging first.

CentOS 7: Fresh install AlmaLinux 9 + data migration is the safest path. Two-step ELevate is possible but riskier.

Master AlmaLinux Administration

Get everything you need to manage your AlmaLinux servers:

Browse AlmaLinux Books →
Share this article:
Dargslan Editorial Team (Dargslan)
About the Author

Dargslan Editorial Team (Dargslan)

Collective of Software Developers, System Administrators, DevOps Engineers, and IT Authors

Dargslan is an independent technology publishing collective formed by experienced software developers, system administrators, and IT specialists.

The Dargslan editorial team works collaboratively to create practical, hands-on technology books focused on real-world use cases. Each publication is developed, reviewed, and...

Programming Languages Linux Administration Web Development Cybersecurity Networking

Stay Updated

Subscribe to our newsletter for the latest tutorials, tips, and exclusive offers.