As of June 30, 2024, CentOS 7 will reach its end of life (EOL). That means it will no longer receive updates, bug fixes, critical security patches, or any new features. It is very important to migrate to a supported operating system to maintain the functionality and security of your systems. AlmaLinux is a reliable alternative to CentoOS. It’s a community-driven enterprise distribution that is binary compatible with Red Hat Enterprise Linux (RHEL). It’s an environment similar to what CentOS users are used to as well as being free and open source.
This tutorial will walk you through the process of migrating from CentOS 7 to AlmaLinux 8 and the AlmaLinux 9 version.
Prerequisites
Before starting the migration, make sure that you have:
- At least 20 GB of free space, since the migration process can require significant temporary space as well as for downloading and installing new packages. The needed space on your system could be potentially higher, depending on the size of your backup. You can always check the disk free space by running the df -h command.
- You need root or sudo permissions to your system since the commands we will be running require higher administrative access for the upgrade process.
- Make sure that you have a fast and stable internet connection, to avoid the risk of interruptions and also don’t cancel the operation after you start the process.
- Check your power supply and make sure that you have redundant power sources if needed.
Step 1: Backup your data
It is important to back up your data before this major upgrade between distributions. So ensure you have a comprehensive backup strategy that covers all critical data, configurations, and system settings. Store your backups on a separate disk, external storage, or a remote backup server to ensure they are safe in case the migration process encounters issues. Here’s a checklist of what to back up:
- System Configuration Files (/etc)
- User Data (/home)
- Application Data (databases, web server data)
- Custom Scripts and Cron Jobs
- Service Configuration
- Installed Package List
- Important Logs (/var/log)
- SSH Keys and Configuration
- Custom Network Configuration
- Virtual Hosts and Containers
- Email Server Configuration
- Firewall and Security Configurations
Step 2: Update your CentOS 7 System
First, we will verify our current CentOS version. We can do so by running the following command:
cat /etc/centos-release
Next, we need to ensure that our CentOS 7 system is up to date before we run the migration:
sudo yum update -y
Reboot the server so you can apply the latest kernel version:
sudo reboot
Step 3: Install EPEL Repository
For the migration process, we need to check if we already have the Extra Packages for Enterprise Linux (EPEL) repository that contains the necessary additional packages.
sudo yum install epel-release -y
You will get the output on the screen that the process is complete:
Step 4: Install the Migration Script
Now we will install the ‘Elevate’ migration script to assist in the migration process. What it does is, it replaces CentOS 7 repositories with AlmaLinux 8 repositories. It also handles package installation, configures system configuration, and preserves user data so no or little reconfiguration is needed after the migration.
This command will install the elevate-release package with the project repo and GPG key:
sudo yum install -y http://repo.almalinux.org/elevate/elevate-release-latest-el$(rpm –eval %rhel).noarch.rpm
We also need to install the Leapp packages and necessary data for AlmaLinux migration:
sudo yum install -y leapp-upgrade leapp-data-almalinux
Next, start a pre-upgrade check, which is an important step. The Leapp utility will create a report file under the path /var/log/leapp/leapp-report.txt where we will get information about potential problems and some recommended solutions. In this phase, the utility doesn’t install any rpm packages.
sudo leapp preupgrade
We will get the similar output below, and make sure you review it, especially if you have some custom configuration.
At the end of the process, you might get a warning related to the package that doesn’t exist in AlmaLinux:
Let’s open the answer file with details:
sudo cat /var/log/leapp/answerfile
Here we can see that this PAM module is no longer available on newer version, because it has been replaced with SSSD. Leaving this package in the system may cause problems. We need to confirm the answer to True, so run the following command:
sudo leapp answer –section remove_pam_pkcs11_module_check.confirm=True
After editing the answer file, run the pre-upgrade check again to ensure all required confirmations are in place.
sudo leapp preupgrade
Step 5: Migrate CentOS 7 to AlmaLinux 8
After we have reviewed our pre-upgrade log file and determined that we are ready to proceed, we can start with the process.
sudo leapp upgrade
Based on the instructions, we need to reboot the server.
sudo reboot
The reboot will disconnect the SSH connection and during the boot process and by using the dedicated boot entry, the Leapp will upgrade needed packages and reboot again automatically.
When the process is complete, we can check the current release version on our server:
cat /etc/os-release
This confirms that our system is running the AlmaLinux 8.9 version.
Step 6: Upgrade AlmaLinux 8 to AlmaLinux 9
AlmaLinux 8 will receive security support until May 31st 2029, but the active support ends on May 31st 2024, so you can consider upgrading to the latest AlmaLinux version to keep the benefits of the active support.
We need to make sure to clean our yum.conf file and remove everything from the exclude line especially that refers to elevate or leapp related to the previous migration.
sudo vi /etc/yum.conf
Also, change the dnf.conf file and remove similar entries if there is an ‘excluded’ line.
sudo vi /etc/dnf/dnf.conf
Check packages left from CentOS 7 by using the rpm command:
rpm -qa | grep ‘\.el7’
You will get the similar output:
Check dependencies and if any other packages depend on them.
for pkg in $(rpm -qa | grep ‘\.el7’); do rpm -q –whatrequires $pkg; done
We can proceed by removing the leftover packages:
sudo rpm -e $(rpm -qa | grep ‘\.el7’)
Now we will clean up the package manager cache to free up space, remove any unnecessary data and verify the system integrity:
sudo dnf clean all
sudo dnf autoremove -y
sudo dnf check
We can then proceed to elevate-release package installation from the project repo:
sudo yum install -y http://repo.almalinux.org/elevate/elevate-release-latest-el$(rpm –eval %rhel).noarch.rpm
Next install leapp packages and migration data again:
sudo yum install -y leapp-upgrade leapp-data-almalinux
For the transition between AlmaLinux 8 and AlmaLinux 9, it is recommended to disable SELinux and also the firewalld ZoneDrifting feature.
First, edit the SELinux configuration file and change to option ‘disabled‘.
sudo vi /etc/sysconfig/selinux
Reboot the server to apply the changes:
sudo reboot
After the reboot, log in to your system and edit the firewalld option:
sudo vi /etc/firewalld/firewalld.conf
Here we will set AllowZoneDrifting option to ‘no‘
Save the file and run the pre-upgrade check, to make sure everything is prepared for the upgrade:
sudo leapp preupgrade
Based on the output, we need to confirm the answer again:
sudo leapp answer –section check_vdo.no_vdo_devices=True
In the report, we also got the error for the network configuration:
Network configuration for unsupported device types detected
Summary: RHEL 9 does not support the legacy network-scripts package that was deprecated in RHEL 8 in favor of NetworkManager. Files for device types that are not supported by NetworkManager are present in the system. Files with the problematic configuration:
– /etc/sysconfig/network-scripts/ifcfg-enp0s3
The official recommendation from the AlmaLinux team is to consider removing the file.
sudo rm /etc/sysconfig/network-scripts/ifcfg-enp0s3
Review the exact file name from the report in your case, as it can be different.
We can also remove the make-devel package as it can often conflict with the upgrade process:
sudo dnf remove make-devel
Now we can proceed to the upgrade by running the command:
sudo leapp upgrade
This will take some time and after the process, we need to reboot again.
sudo reboot
After the process, log in to your system and check the current version:
cat /etc/os-release
It is recommended that you check logs and packages left from the previous OS version, so consider removing them in a similar way we did for old CentOS 7 packages.
rpm -qa | grep el8
sudo cat /var/log/leapp/leapp-report.txt
sudo cat /var/log/leapp/leapp-upgrade.log
Migrating from CentOS 7 to AlmaLinux is a crucial step to ensure your systems remain secure and supported beyond the CentOS 7 end-of-life date. By following this guide, you can migrate your system with minimal disruption and ensure a smooth transition to newer AlmaLinux versions.