How to Migrate from CentOS to AlmaLinux or Rocky Linux

If you're still running a CentOS Linux 8 (or earlier) server, migrating to AlmaLinux or Rocky Linux is strongly recommended given CentOS Linux's end of life. This guide covers both the in-place migration approach and the safer fresh-install alternative.

Why Migrate

CentOS Linux 8 reached end of life in December 2021, meaning no further security updates — continuing to run it exposes your server to unpatched vulnerabilities indefinitely.

Two Migration Approaches

ApproachProsCons
In-place migration scriptNo downtime for data transfer, fasterCarries forward any existing system issues/cruft
Fresh install + data migrationClean slate, more reliable long-termRequires more manual work and planning downtime

Recommended Approach: Fresh Install (More Reliable)

For production systems, a fresh install with careful data migration is generally the more reliable long-term choice, avoiding any accumulated configuration drift or edge cases the in-place script might not perfectly handle.

Fresh Install Migration Steps

Step 1 — Provision a New AlmaLinux/Rocky Linux VPS

See How to Get Started with AlmaLinux/Rocky Linux on a VPS.

Step 2 — Document Your Current CentOS Server's Configuration

rpm -qa > installed-packages.txt
cp -r /etc/nginx /backup/
cp -r /etc/httpd /backup/
crontab -l > crontab-backup.txt

Step 3 — Install Equivalent Software on the New Server

Install matching versions of your web server, database, and runtime using this knowledge base's AlmaLinux/Rocky Linux guides.

Step 4 — Migrate Databases

mysqldump -u root -p --all-databases | gzip > backup.sql.gz
scp backup.sql.gz user@NEW_SERVER_IP:/tmp/
gunzip -c /tmp/backup.sql.gz | mysql -u root -p

Step 5 — Migrate Application Files

rsync -avz /var/www/ user@NEW_SERVER_IP:/var/www/

Step 6 — Test Thoroughly Before Cutover

Follow the same testing-before-DNS-cutover approach covered in How to Migrate a Full VPS to a New Provider.

Step 7 — Update DNS

See How to Migrate DNS to a New Provider Without Downtime for the low-downtime technique.

In-Place Migration (Alternative, Faster but Riskier)

Both AlmaLinux and Rocky Linux provide official migration scripts that convert an existing CentOS installation without a full reinstall. Given the risk of an in-place conversion on a production system, this approach is best reserved for non-critical systems, or attempted first on a test/staging clone of your production server.

Always take a full snapshot/backup before attempting an in-place migration, regardless of which official tool you use — see Backup Strategy 101: The 3-2-1 Rule Explained.

Post-Migration Checklist

  • Verify all services start correctly and function as expected
  • Confirm firewalld rules match your intended configuration (not just carried-over iptables rules)
  • Check SELinux status and address any new context-related issues — see Understanding SELinux Basics on AlmaLinux/Rocky Linux
  • Update any internal documentation referencing the old OS/package manager commands
  • Set up automatic security updates on the new system

Common Errors

Services fail to start after in-place migration — review migration script logs carefully; some manually-installed or third-party packages may not migrate cleanly and require reinstallation.

SELinux denials appear that weren't present on CentOS — if CentOS was previously running in permissive mode or with SELinux disabled, moving to a properly enforcing AlmaLinux/Rocky Linux system will surface these; address them via correct contexts rather than disabling SELinux.

Continue Reading

Browse more articles in AlmaLinux & Rocky Linux.

  • centos migration, migrate to almalinux, migrate to rocky linux, centos eol
  • 0 أعضاء وجدوا هذه المقالة مفيدة
هل كانت المقالة مفيدة ؟

مقالات مشابهة

AlmaLinux vs Rocky Linux vs CentOS: What Happened to CentOS?

If you're choosing a RHEL-compatible Linux distribution for your VPS, understanding the CentOS...

How to Get Started with AlmaLinux/Rocky Linux on a VPS

This guide covers the essential first steps after deploying a new AlmaLinux or Rocky Linux VPS...

How to Use dnf: The Package Manager for AlmaLinux & Rocky Linux

dnf (Dandified YUM) is the package manager for AlmaLinux, Rocky Linux, and other RHEL-family...

How to Configure firewalld on AlmaLinux/Rocky Linux

firewalld is the default firewall management tool on AlmaLinux and Rocky Linux, using a...

How to Install Nginx on AlmaLinux/Rocky Linux

This guide covers installing and configuring Nginx on AlmaLinux or Rocky Linux, including the...