Thursday, May 16, 2024

Migrating from CentOS 7 to Oracle Linux 8: A Comprehensive Guide


 CentOS 7 will reach its end of life (EOL) on June 30, 2024. This means that this operating system will no longer receive security updates or support. If you're looking for a reliable alternative, Oracle Linux 8 is the perfect choice!

This guide will walk you through the migration process in a simple and easy-to-understand manner.

Before You Begin

Important: Upgrading directly from CentOS 7 to Oracle Linux 9 is not possible. You must first migrate to Oracle Linux 8.

Upgrade in-place: This means updating your current OS to a newer version without having to reinstall everything.

Important Notes:

  • It is highly recommended to create a full system backup before starting the migration process.
  • If you are uncomfortable with a full backup, you can use the provided commands to archive important directories.

Step 1: Back Up Your System

Data security is top priority! Make sure all your important data is safe. Here are two ways to back up your system:

  1. Full System Backup:

This is the most comprehensive option, but it can be quite time-consuming.

  1. Partial Backup:

Use the following command to archive important directories:

sudo tar czf /centos7-data.tar.gz \
     --exclude=/centos7-data.tar.gz \
     --exclude=/dev \
     --exclude=/mnt \
     --exclude=/proc \
     --exclude=/sys \
     --exclude=/tmp \
     --exclude=/media \
     --exclude=/lost+found \
     /

This command will create a backup named "centos7-data.tar.gz" on the root partition (/). It is recommended to transfer this file to another storage device for safekeeping.

Step 2: Update Your System

Ensure your CentOS 7 system is fully updated by running the following command in your terminal:

sudo yum update

Step 3: Migrate to Oracle Linux 8

We will use a tool called ELevate to assist with the migration.

Step 3.1: Install the ELevate Tool

sudo yum install http://repo.almalinux.org/elevate/elevate-release-latest-el$(rpm --eval %rhel).noarch.rpm

Step 3.2: Install Leapp and Migration Data

Leapp is a tool designed for in-place upgrades on Red Hat Enterprise Linux systems.

sudo yum install leapp-upgrade leapp-data-oraclelinux

This command may prompt you to accept GPG keys. Accept them without hesitation.

Step 3.3: Pre-Upgrade Check

Before proceeding, it is advisable to run a pre-upgrade check to identify potential issues. This is done with the following command:

sudo leapp preupgrade

The check may reveal some errors, but don't worry! These can usually be fixed. This guide provides three commands to address common errors. Run all three if necessary.

Once you've addressed the errors, rerun the pre-upgrade check:

sudo leapp preupgrade

A green-colored report indicates that everything is ready for the upgrade.

Step 3.4: Perform the Migration

It's time for the main part! Run the following command to initiate the migration from CentOS 7 to Oracle Linux 8:

sudo leapp upgrade

The upgrade process may take some time, depending on your internet speed. Be patient and avoid using the system during this stage.

Step 4: Reboot and Verify

Once the migration is complete, you will be prompted to reboot the system. After rebooting, you will see a new option named "ELevate-Upgrade-Initramfs" in the GRUB menu. Your system will automatically boot into this option.

The upgrade process may involve background activities, so be patient as the system reboots.

Optional: Check OS Version

You can verify the successful migration by checking the OS version:

cat /etc/oracle-release

Post-Installation Steps

Remove EPEL Repository (If Applicable): The EPEL repository may cause compatibility issues. If you use it, remove it with:

sudo dnf remove epel-release

You can then add the EPEL 8 repository, which is compatible with Oracle Linux 8.

Post-Installation Steps (Continued)

Upgrade Your System:

sudo dnf update

Remove CentOS 7 Packages:

Use the following command to find and list any remaining CentOS 7 packages:

sudo rpm -aq | grep el7

Then, remove those packages one by one with the following command, replacing <package_name> with the actual package name:

sudo dnf remove <package_name>

Make sure to carefully review the list before removing any packages to avoid accidentally removing something necessary.

Remove CentOS 7 Configuration Files:

Remove any leftover CentOS 7 configuration files to ensure a clean transition to Oracle Linux 8. Run the following command:

sudo rm -rf /etc/yum.repos.d/CentOS-*

Change Hostname (Optional):

You may want to change your system's hostname to conform to Oracle Linux standards. Use the following command, replacing <new_hostname> with your desired hostname:

sudo hostnamectl set-hostname <new_hostname>

Adjust Firewall (Optional):

Oracle Linux 8 uses a different firewall than CentOS 7. You may need to adjust your firewall rules to suit your needs. Consult the Oracle Linux documentation for more information on managing the firewall.

Important Notes:

  • After migration, it is recommended to review your system logs for any potential errors or issues.
  • You should also update any third-party applications and services installed on your system to ensure compatibility with Oracle Linux 8.
  • The official Oracle Linux 8 documentation is a valuable resource for further information about the operating system and how to manage it.

Conclusion

Migrating from CentOS 7 to Oracle Linux 8 can be accomplished smoothly by following the steps outlined in this guide. With careful planning and preparation, you can ensure a seamless and trouble-free transition to this new and reliable operating system.


0 comments:

Post a Comment