Back up the system and ensure that CentOS 7 or 8 is run, update the system and confirm the architecture support; 2. Download the official almalinux-deploy.sh script and execute it to automatically replace the warehouse and core package; 3. Verify the distribution information, kernel and warehouse configuration after restarting the system; 4. Check the third-party source, reinstall the EPEL, and confirm that the service is normal; 5. It is recommended to use a brand new installation in the production environment to reduce risks, and finally it can be smoothly migrated to long-term supported AlmaLinux.
Migrating from CentOS to AlmaLinux is a common move, especially since CentOS 8 reached end-of-life in December 2021. AlmaLinux, being a binary-compatible, community-driven fork of RHEL (like CentOS used to be), is a solid long-term replacement. Here's how to safely and effectively migrate your CentOS system to AlmaLinux.

? Before You Begin: Backup and Preparation
Before making any changes, ensure you have a complete system backup. This migration modifies core system packages and configuration files — any mistake could render the system unbootable.
Steps:

- Take a full system snapshot (if using a VM or cloud instance).
- Back up critical data and configurations.
- Ensure you're running CentOS 7 or CentOS 8 (migration tools support both).
- Update your current system:
sudo yum update -y # CentOS 7 sudo dnf update -y # CentOS 8
Also, check your architecture : AlmaLinux supports x86_64 and aarch64. Make sure your system is supported.
? Step-by-Step Migration Using AlmaLinux Migration Script
AlmaLinux provides an official migration tool called almalinux-deploy
, which automates the switch from CentOS (or other RHEL forks) to AlmaLinux.

1. Download and Run the Migration Script
Run the following commands as root or with sudo
:
curl -O https://raw.githubusercontent.com/AlmaLinux/almalinux-deploy/master/almalinux-deploy.sh
Verify the script (optional but recommended):
less almalinux-deploy.sh
Then execute it:
sudo bash almalinux-deploy.sh
? The script will:
- Detect your current OS (CentOS 7 or 8)
- Replace CentOS repositories with AlmaLinux ones
- Replace key system packages (like
centos-release
→alma-release
)- Clean package cache and regenerate it
2. Wait for Completion
The script handles most of the heavy lifting. It may take a few minutes depending on your system and internet speed.
You'll see output like:
Replacing CentOS Linux with AlmaLinux... Updating repositories... Installing alma-release package... Cleaning package cache...
3. Reboot the System
After the script finishes:
sudo reboot
Once the system comes back up, log in and verify the migration.
? Verify the Migration
Run the following commands to confirm you're now on AlmaLinux:
cat /etc/redhat-release # Should output: AlmaLinux release XX (Codename) uname -r # Kernel should still be RHEL-compatible (eg, 4.18.0-xxxx.el8.x86_64) rpm -q centos-release # Should return "package is not installed"
Also check:
dnf repolist # Should show AlmaLinux repositories (AppStream, BaseOS, etc.)
?? Post-Migration Checks
Even though the migration is automated, a few things deserve attention:
- Third-party repos : Some may still reference CentOS. Update repo URLs to point to AlmaLinux equivalents if available.
- Eg, update
baseurl
in/etc/yum.repos.d/
files if needed.
- Eg, update
- EPEL : Reinstall EPEL to ensure compatibility:
sudo dnf install epel-release -y
- Kernel updates : Going forward, you'll receive kernels from AlmaLinux, not CentOS.
- Services : Confirm all critical services (nginx, MySQL, Docker, etc.) are running normally.
? What Doesn't Change
- Installed software and user data remains intact.
- Filesystem layout stays the same.
- Configuration files (eg, in
/etc/
) are preserved. - Your IP, hostname, and SSH keys are untouched.
? Alternative: Clean Install (Recommended for Production)
While in-place migration works, for production environments , consider a clean AlmaLinux install:
- Set up a new AlmaLinux server.
- Migrate data and apps.
- Test thoroughly.
- Switch over via DNS or load balancer.
This reduces risk and ensures a clean, predictable environment.
Final Notes
The migration from CentOS to AlmaLinux is straightforward thanks to the official almalinux-deploy
tool. It's safe for most use cases, but always have a rollback plan .
AlmaLinux offers long-term support (until 2029 for v8, 2031 for v9), making it a reliable CentOS successor.
Basically, run the script, reboot, and you're on AlmaLinux — no need to reinvent the wheel.
The above is the detailed content of Migrate CentOS to AlmaLinux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

In Linux system, using the usermod command to add users to the secondary group is: 1. Execute the sudousermod-a-G group name username command to add, where -a means append to avoid overwriting the original secondary group; 2. Use groups username or grep group name /etc/group to verify whether the operation is successful; 3. Note that the modification only takes effect after the user logs in again, and the main group modification should use the -g parameter; 4. You can also manually edit the /etc/group file to add users, but be careful to avoid system abnormalities caused by format errors.

To migrate from CentOS8 to AlmaLinux or RockyLinux, follow the clear steps. First, choose AlmaLinux (suitable for long-term enterprise support) or RockyLinux (emphasizing exactly the same as RHEL) according to your needs. Secondly, prepare the system environment: update the software package, back up key data, check third-party repositories and disk space. Then, the conversion is automatically completed using the official migration script. RockyLinux needs to clone the repository and run the switch-to-rocky.sh script. AlmaLinux replaces the repository and upgrades with one click through the remote deployment script. Finally, verify system information, clean up residual packets, and update GRUB and ini if ??necessary

To correctly install the local RPM file and handle dependencies, you should first use dnf to install it directly, because it can automatically obtain the required dependencies from the configured repository; if the system does not support dnf, you can use yum's localinstall command instead; if the dependency cannot be resolved, you can manually download and install all related packages; finally, you can also forcefully ignore the dependency installation, but this method is not recommended. 1. Use sudodnfinstall./package-name.rpm to automatically resolve dependencies; 2. If there is no dnf, you can use sudoyumlocalinstall./package-name.rpm; 3. Force installation and execute sudorpm-ivh--nod

AminimalinstallofCentOSisalightweightsetupthatincludesonlyessentialcomponents,makingitidealforserversorsystemsrequiringfullcontrol.Itcontainscoreutilitieslikebash,yum/dnf,networkingtools,andsecuritypackages,whileexcludingdesktopenvironments,webserver

How to set a static IP address using nmcli on CentOS8 or 9? 1. First run the nmcliconnectionshow and ipa commands to view the current network interface and its configuration; 2. Use the nmcliconnectionmodify command to modify the connection configuration, specify parameters such as ipv4.methodmanual, ipv4.addresses (such as 192.168.1.100/24), ipv4.gateway (such as 192.168.1.1), and ipv4.dns (such as 8.8.8.8). 3. Run the nmcliconnectiondown and up commands to restart the connection to make the changes take effect, or

Installing and configuring fail2ban on CentOS is not complicated, it mainly includes the following steps: 1. Install fail2ban using yum; 2. Manually enable and start the service; 3. Create a jail.local file for custom configuration; 4. Set SSH defense rules, including enabling sshd, specifying the blocking time and retry times; 5. Configure firewalld as an action actuator; 6. Regularly check the blocking IP and logs. Fail2ban detects abnormal login behavior through monitoring logs and automatically blocks suspicious IPs. Its core mechanism relies on key parameters such as bantime (banned time), findtime (statistic window time) and maxretry (maximum failure number).

KernelCare and kpatch are both tools for implementing hot patches in the Linux kernel, but the applicable scenarios are different. 1. KernelCare is a commercial service that supports CentOS, RHEL, Ubuntu and Debian, automatically applies patches without restarting, and is suitable for hosting service providers and enterprise production environments; 2. kpatch is an open source tool developed by Red Hat. It is based on the ftrace framework and requires manual construction of patch modules. It is suitable for RHEL and compatible systems, and is suitable for organizations that need to finely control the patch process or use customized kernels. When choosing, automation requirements, system distribution, whether official support is required, and the degree of control over open source tools should be considered. Neither of them can fix all vulnerabilities, some still need to be restarted, and

To list all running services, use systemctllist-units-type=service-state=running. 1. This command will display the service currently in the "running" state, including service name, description, status and other information; 2. If only the service name is needed, the --no-legend parameter can be added to simplify the output and facilitate script processing; 3. For services with status "loadedactive(exited)" or "loadedactive(waiting)" are not running, --state=running has automatically filtered these entries; 4. When extracting the service name in the script, you can use awk'
