How to migrate from CentOS to AlmaLinux

AlmaLinux
AlmaLinux

The main motivation behind the creation of AlmaLinux was to be a viable replacement for CentOS Linux at the time of its shift from an enterprise-stable operating system to an upstream development branch of RHEL.

Now that AlmaLinux is released, it still leaves CentOS users wondering how to switch operating systems. Ideally, this should be done as seamlessly as possible, to prevent downtime, loss of data, etc. In this guide, we’ll show you the step by step instructions to migrate from CentOS to AlmaLinux with just a few commands.

In this tutorial you will learn:

  • How to migrate from CentOS to AlmaLinux


Completing the merge from CentOS to AlmaLinux

CategoryRequirements, Conventions or Software Version Used
SystemAlmaLinux and CentOS
SoftwareN/A
OtherPrivileged access to your Linux system as root or via the sudo command.
Conventions# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

WARNING
Although we’ve tested these methods to work on our own system without any problems, it’s recommended that you make a full backup of your own system before proceeding.

Method 1: Migrate from CentOS to AlmaLinux



dnf distro-sync -y

The first method will use the official almalinux-deploy script that’s hosted on GitHub. Follow along with the steps below to download the script and use it to perform the migration from CentOS to AlmaLinux. This script takes certain scenarios into consideration like migrating DirectAdmin, cPanel, Plesk, and other programs as seamlessly as possible. Check the GitHub page for full details.

  1. Start by downloading the script and giving it execute permissions.# curl -O https://raw.githubusercontent.com/AlmaLinux/almalinux-deploy/master/almalinux-deploy.sh # chmod +x almalinux-deploy.sh
  2. Next, execute the script as root or with sudo.# bash almalinux-deploy.sh
  3. After the script performs a few initial checks, it will begin the process of removing, reinstalling, downgrading, and upgrading certain packages in order to synchronize the system with the current AlmaLinux release. This process will take some time, but once it’s done, you can reboot the system and load into AlmaLinux.# reboot
  4. Once the computer is done booting up, verify that the system has migrated successfully by checking the /etc/redhat-release file.
    # cat /etc/redhat-release AlmaLinux release 8.3 (Purple Manul) Also make sure that the system is set to boot the AlmaLinux kernel by default.# grubby –info DEFAULT | grep AlmaLinux title=”AlmaLinux (4.18.0-240.el8.x86_64) 8″

That’s all there is to it. As long as you didn’t encounter any errors along the way, you’ve successfully migrated your system from CentOS to AlmaLinux.

Method 2: Migrate from CentOS to AlmaLinux

The second method is more of a manual migration. This was the first approach to be used when AlmaLinux was first released, but has since been superseded by the previous method mentioned. For some, this second method may work better, and if nothing else, it’s kept for historial purposes or as an alternative method.

Open a command line terminal and follow along with us below to migrate from CentOS to AlmaLinux.

  1. Start by updating CentOS with all the latest packages.$ sudo dnf update -y
  2. Next, it may be necessary to reboot the system for all the changes to take effect – especially for new kernel related packages.$ sudo reboot
  3. Now it’s time to remove some CentOS packages. If you have GNOME installed, there will be a few extra packages we have to remove like CentOS wallpapers and other branding. Execute the command below if you have the GUI installed.$ sudo rpm -e –nodeps centos-backgrounds centos-indexhtml centos-gpg-keys centos-linux-release centos-linux-repos centos-logos If you don’t have GNOME installed, you can use the shorter command below to remove all the CentOS-specific packages, keys, etc.$ sudo rpm -e –nodeps centos-gpg-keys centos-linux-release centos-linux-repos
  4. Next, let’s download and install the latest AlmaLinux release package. At the time of this writing, it’s 8.3, but you should specify a different version if there’s a newer one available.$ sudo rpm -ivh https://repo.almalinux.org/almalinux/8.3-beta/BaseOS/x86_64/os/Packages/almalinux-release-8.3-2.el8.x86_64.rpm
  5. Once installation is done, execute the following command to complete the migration from CentOS to AlmaLinux. This command will take some time to complete, as many packages will be upgraded, downgraded, and installed (on our vanilla CentOS install, that was over 2500 packages). But when it’s done, you’ll have a system running AlmaLinux.$ sudo dnf distro-sync -y
  6. Once the process is finished, you can reboot and load back into AlmaLinux.$ sudo reboot

Be sure to select AlmaLinux from the startup options when booting, although it should be selected by default.



Select AlmaLinux upon boot

For more verification, you can run the hostnamectl command to see that your system has completely migrated over to AlmaLinux.Verify that the system is now running AlmaLinux

Closing Thoughts



In this guide, we saw how to migrate a system from CentOS Linux to AlmaLinux. Being that CentOS (although not CentOS Stream) and AlmaLinux are forks of RHEL, it’s a relatively simple switch once you know the right packages to remove, and how to sync the distribution with dnf package manager.

After following the steps, you should have a standard AlmaLinux system which can continue to retrieve updates as normal. Hopefully this will help you reduce downtime and continue to deliver the stability that you’ve had for years with CentOS.

Troubleshooting

You may run into the following error when trying to execute the dnf distro-sync command.

$ sudo dnf distro-sync -y
Error: 
 Problem: package libreport-plugin-rhtsupport-2.9.5-15.el8.x86_64 requires libreport = 2.9.5-15.el8, but none of the providers can be installed
  - libreport-2.9.5-15.el8.x86_64 does not belong to a distupgrade repository
  - problem with installed package libreport-plugin-rhtsupport-2.9.5-15.el8.x86_64

The problem is with the libreport-plugin-rhtsupport-2.9.5-15.el8.x86_64 package, which is just a plugin to facilitate Red Hat support channels. It’s not needed in AlmaLinux, so you should just remove it before proceeding.

$ sudo dnf remove libreport-plugin-rhtsupport-2.9.5-15.el8.x86_64

Now you should be able to use the dnf distro-sync command to successfully complete the migrate to AlmaLinux.

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.