CentOS 8 reached End-of-Life on December 31st, 2021. If you are still running CentOS 8, your server is no longer receiving security updates, and standard package installation commands will fail.
To save your server without reinstalling, you can perform an in-place migration to a supported RHEL-clone like AlmaLinux 8 or Rocky Linux 8.
This process replaces core system packages. While generally safe, things can go wrong.
Create a VPS Snapshot before proceeding.
Step 1: Fix the Repositories (Crucial!)
Because CentOS 8 is EOL, the standard mirrors are offline. Before you can download the migration tools, you must point your package manager to the archive (vault).
Run the following commands to fix dnf:
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
dnf update -y
Option A: Migrate to AlmaLinux 8 (Recommended)
AlmaLinux provides a robust migration script.
- Download the script:
curl -O https://raw.githubusercontent.com/AlmaLinux/almalinux-deploy/master/almalinux-deploy.sh - Run the script:
sudo bash almalinux-deploy.sh - Wait: The script will verify your system, download AlmaLinux packages, and replace the CentOS ones. This takes some time.
-
Reboot: Once finished, reboot your server.
reboot
Verification:
After rebooting, check your release file:
cat /etc/redhat-release
# Output should be: AlmaLinux release 8.x
Option B: Migrate to Rocky Linux 8
Rocky Linux is founded by the original creator of CentOS and offers a similar migration path.
- Download the script:
curl https://raw.githubusercontent.com/rocky-linux/rocky-tools/main/migrate2rocky/migrate2rocky.sh -o migrate2rocky.sh - Make it executable and run it:
chmod +x migrate2rocky.sh sudo ./migrate2rocky.sh -r - Wait & Reboot: Let the script finish and then restart your server.
Option C: CentOS Stream 8
If you prefer to stay within the CentOS ecosystem (but with a "rolling release" model instead of fixed releases), you can switch to Stream.
dnf install centos-release-stream -y
dnf swap centos-{linux,stream}-repos -y
dnf distro-sync -y
reboot