Upgrade / Elevate CentOS 7 to AlmaLinux 8
As CentOS 7 nears its end of life (EOL), the importance of migrating to a supported and stable Linux distribution cannot be overstated. AlmaLinux, a community-driven, open-source fork of Red Hat Enterprise Linux (RHEL), has emerged as a leading replacement, offering long-term support, binary compatibility with RHEL, and a seamless transition for CentOS users. This article provides a comprehensive guide on how to Upgrade / Elevate CentOS 7 to AlmaLinux 8 using the ELevate tool, ensuring a smooth migration and continued access to vital security updates.
Introduction: Why Upgrade to AlmaLinux 8?
CentOS 7’s impending end of life in June 2024 means the cessation of regular updates, security patches, and bug fixes. Continuing to run CentOS 7 after this date leaves your system vulnerable to security exploits and potential incompatibilities with newer software. AlmaLinux 8 offers a compelling alternative, providing continued support, regular security updates, and long-term viability until at least 2029.
AlmaLinux’s binary compatibility with RHEL is a significant advantage. It allows you to continue using your existing tools, applications, and workflows with minimal disruption. This makes AlmaLinux 8 an ideal choice for both enterprises and individual users seeking a reliable and well-supported operating system. It is a great solution when you want to Upgrade / Elevate CentOS 7 to AlmaLinux 8.
Key Considerations Before Upgrading
Prior to initiating the upgrade process from CentOS 7 to AlmaLinux 8, careful preparation is crucial for a smooth and successful transition. These preparatory steps mitigate risks and ensure data integrity.
Backup Your Data
Upgrading an operating system inherently carries risks, including the potential for data loss. Creating a complete system backup, including databases, application data, and configuration files, is paramount. Tools like rsync, tar, or Bacula can be utilized for backups. Cloud backup solutions like Rclone offer off-site redundancy. A full backup is a must when you Upgrade / Elevate CentOS 7 to AlmaLinux 8.
Review Installed Packages
Some packages installed on CentOS 7 may lack direct equivalents in AlmaLinux 8. A thorough review of currently installed packages is essential to identify potential compatibility issues.
List all installed packages using the following command:
$ sudo rpm -qa
This command allows you to identify software that might require updates, alternative versions, or removal before or after the upgrade to AlmaLinux 8.
System Requirements
Ensure your system meets the minimum hardware requirements for AlmaLinux 8:
- CPU: 2 GHz or higher
- RAM: 2 GB minimum (4 GB recommended)
- Disk Space: 20 GB minimum
Step-by-Step Guide: How to Upgrade CentOS 7 to AlmaLinux 8
AlmaLinux provides the ELevate tool to streamline the migration from CentOS 7 to AlmaLinux 8. This tool facilitates in-place upgrades, eliminating the need for a complete system reinstallation.
Step 1: Update Your CentOS 7 System
Before initiating the migration, updating CentOS 7 to the latest available package versions is crucial. However, because the official CentOS 7 repositories are no longer actively maintained, you need to switch to the CentOS vault or utilize the AlmaLinux mirror.
To switch to the AlmaLinux CentOS 7 mirror, execute the following commands:
$ sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://el7.repo.almalinux.org/centos/CentOS-Base.repo
$ sudo curl https://repo.almalinux.org/elevate/el7/elevate.repo -o /etc/yum.repos.d/elevate.repo
Now, upgrade the system with the latest available updates:
$ sudo yum upgrade -y
$ sudo reboot
Step 2: Install the ELevate Tool
After updating CentOS 7, the next step is to install the ELevate tool, which manages the migration process. This tool handles the transition between CentOS and AlmaLinux without requiring a fresh installation.
First, install the elevate-release package, which contains the repository and GPG key for ELevate:
$ sudo yum install -y http://repo.almalinux.org/elevate/elevate-release-latest-el$(rpm --eval %rhel).noarch.rpm
Now, install the necessary leapp packages, which are used to manage the upgrade and handle AlmaLinux as the target OS:
$ sudo yum install -y leapp-upgrade leapp-data-almalinux
Step 3: Perform a Pre-Upgrade Check
The pre-upgrade check helps identify potential issues that could hinder the upgrade process. The leapp utility performs this check and generates a detailed report of any problems, including potential blockers. No packages are installed at this stage, ensuring your system remains unchanged until the issues are addressed.
Run the pre-upgrade check using the following command:
$ sudo leapp preupgrade
The leapp utility generates a report located at /var/log/leapp/leapp-report.txt
. Review this report carefully. It contains a summary of potential issues along with recommended solutions.
Step 4: Address Pre-Upgrade Issues
The pre-upgrade check often highlights issues that must be resolved before proceeding. These issues often relate to hardware drivers, configuration settings, or unsupported packages.
Some common fixes for CentOS 7 include:
- Blacklisting the
pata_acpi
module:
$ sudo rmmod pata_acpi
- Enabling root login via SSH (if required):
$ echo PermitRootLogin yes | sudo tee -a /etc/ssh/sshd_config
- Confirming removal of the
pam_pkcs11
module:
$ sudo leapp answer --section remove_pam_pkcs11_module_check.confirm=True
For more common issues, refer to the ELevate Frequent Issues page for guidance on troubleshooting and resolving problems.
Step 5: Start the Upgrade Process
Once the pre-upgrade issues are resolved, you can initiate the actual upgrade process. This step involves downloading and installing the necessary packages to upgrade CentOS 7 to AlmaLinux 8.
Execute the following command to begin the upgrade:
$ sudo leapp upgrade
The leapp utility downloads the required AlmaLinux 8 packages and starts the upgrade process. This process may take some time, depending on your system’s performance and internet connection speed.
Step 6: Reboot into ELevate-Upgrade-Initramfs
After the upgrade process completes, you will be prompted to reboot the system. Upon reboot, the system will automatically boot into a new entry in GRUB called ELevate-Upgrade-Initramfs.
Reboot the system using:
$ sudo reboot
During this phase, the system applies the upgrade changes. You can monitor the progress directly in the console. Your system reboots automatically after the upgrade is complete.
Step 7: Verify the Upgrade
Once the system reboots after the upgrade, verify that the system is running AlmaLinux 8. Use the following commands to check the OS version:
$ cat /etc/redhat-release
$ cat /etc/os-release
The output should confirm that the system is running AlmaLinux 8.
Additionally, check for any residual CentOS 7 packages:
$ rpm -qa | grep el7
You can also check the log files for any issues encountered during the upgrade:
$ cat /var/log/leapp/leapp-report.txt
$ cat /var/log/leapp/leapp-upgrade.log
If any CentOS 7 packages or configurations remain, you can remove or update them manually.
Post-Migration Steps
After upgrading to AlmaLinux 8, several post-migration steps are essential to ensure smooth system operation.
Reinstall and Reconfigure Applications
Some applications may require reinstallation or reconfiguration after the upgrade. Use dnf, the package manager for AlmaLinux 8, to install and manage packages. For example, to reinstall a package, use:
$ sudo dnf install <package_name>
Apply Regular System Updates
Keep your system updated with the latest security patches and package updates. Use the following command to update your AlmaLinux 8 system regularly:
$ sudo dnf update -y
Review Security Settings
After a major system upgrade, review your security configurations. Ensure that SELinux is enabled and configured correctly:
$ sestatus
Also, review your firewall settings and verify that services like firewalld or iptables are running as expected.
Performance Monitoring
Use performance monitoring tools like top, htop, or nmon to monitor system performance and resource usage. This helps ensure that your upgraded system is running efficiently and can handle its workload. This is very important when you Upgrade / Elevate CentOS 7 to AlmaLinux 8.
Alternative Solutions to Upgrading from CentOS 7
While the ELevate tool offers a convenient in-place upgrade path, alternative solutions exist for migrating from CentOS 7. These methods involve a more hands-on approach but can provide greater control over the migration process.
1. Clean Installation with Data Migration
This approach involves performing a fresh installation of AlmaLinux 8 on a separate partition or a new server and then migrating the necessary data and configurations from the CentOS 7 system.
-
Explanation: This method ensures a clean and uncluttered AlmaLinux 8 installation, free from potential conflicts or compatibility issues arising from the in-place upgrade. It provides a stable and reliable foundation for the new system.
-
Steps:
- Backup: Create a complete backup of the CentOS 7 system.
- Installation: Install AlmaLinux 8 on a new partition or server.
- Data Transfer: Manually transfer data, configuration files, and databases from the CentOS 7 backup to the new AlmaLinux 8 system. Tools like
rsync
orscp
can be used for file transfer. - Configuration: Reconfigure applications and services on the AlmaLinux 8 system to match the previous CentOS 7 setup.
- Testing: Thoroughly test the migrated applications and services to ensure proper functionality.
-
Code Example (rsync):
# On the AlmaLinux 8 system: $ rsync -avz user@centos7_ip:/path/to/data /local/path/
This command uses
rsync
to copy data from the CentOS 7 system to the AlmaLinux 8 system.
2. Containerization with Docker or Podman
This approach involves containerizing the applications and services running on CentOS 7 using Docker or Podman and then deploying these containers on an AlmaLinux 8 host.
-
Explanation: Containerization provides a consistent and isolated environment for applications, regardless of the underlying operating system. This allows for a smooth migration without the need to modify the applications themselves.
-
Steps:
- Dockerize Applications: Create Dockerfiles for each application or service running on CentOS 7.
- Build Images: Build Docker images from the Dockerfiles.
- Deploy Containers: Deploy the Docker containers on an AlmaLinux 8 host.
-
Code Example (Dockerfile):
FROM centos:7 # Install dependencies RUN yum update -y && yum install -y httpd # Copy application files COPY . /var/www/html # Expose port EXPOSE 80 # Start web server CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]
This Dockerfile defines a container based on CentOS 7 that installs Apache (httpd) and copies application files to the web server’s document root. This is another great way to Upgrade / Elevate CentOS 7 to AlmaLinux 8.
Conclusion
Upgrading from CentOS 7 to AlmaLinux 8 is a crucial step for maintaining a secure and stable server environment beyond CentOS 7’s end of life. The ELevate tool simplifies the process, enabling an in-place upgrade without reinstalling your system or losing data. By following the steps in this guide, you can ensure a smooth transition and benefit from continued support and updates from AlmaLinux. Remember to back up your system and address any pre-upgrade issues before starting the upgrade process. This is the best way to Upgrade / Elevate CentOS 7 to AlmaLinux 8.