How to Migrate CentOS 7 to Oracle Linux 8 with Ease

Discover the easy migration path from CentOS 7 to Oracle Linux 8 with our clear, expert guide, making your system upgrade a breeze.

On June 30, 2024, CentOS 7 will reach End-of-Life (EOL). After this date, the operating system will no longer receive security updates or maintenance support. Essentially, CentOS 7 will be retiring from the server platform lineup after many years of reliable service.

Since youโ€™ve landed here, you prefer Oracle Linux as an upgrade path for your CentOS 7 system. Congratulations on your choice! It is an exceptionally reliable server platform from a brand that speaks for itself.

Weโ€™ve also provided migration guides for the other two enterprise Linux distributions, AlmaLinux and Rocky. Now, to complete the trio, this tutorial will seamlessly walk you through transitioning from CentOS 7 to Oracle Linux 8. But before we get to the action, there are a few key points we need to clarify.

CentOS 7 to Oracle Linux Upgrade Path

The latest version of Oracle Linux is 9. However, this guide focuses on migrating to version 8. Why? Because a direct migration from CentOS 7 to Oracle Linux 9 is impossible. Instead, you must first upgrade to Oracle Linux 8 as an intermediary step before moving on to version 9. For a clearer understanding, refer to the image below.

CentOS 7 to Oracle Linux upgrade path.
CentOS 7 to Oracle Linux upgrade path.

If youโ€™re wondering, anย in-place upgrade, as mentioned in the image above, refers to updating the current operating system to a newer version without removing the existing one and manually reinstalling or reconfiguring the system and applications. This means youโ€™re essentially upgrading the OS while itโ€™s running.

Having clarified this, we can now proceed to action. Here is our CentOS 7 system before starting the migration process to Oracle Linux 8.

CentOS 7
CentOS 7

Step 1: Take System Backup

First, letโ€™s ensure all your important data is safe. So, before doing anything else, we strongly recommend making a full system backup so that if something goes wrong, you can restore your system with all the vital data to its previous state.

However, if you do not feel like taking the above approach, you can instead use a command like the one shown below, which will archive all of the more critical directories and their contents in a tar.gz archive.

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 \
     /Code language: Bash (bash)

Feel free to add more โ€œโ€“exclude=โ€ parameters if needed. Finally, the command creates a backup of all files in the โ€œcentos7-data.tar.gzโ€ file located on the root partition (/), which you should ideally transfer to another computer or drive, for example, using the SCP command.

Step 2: Update All Software

Ensure you haveย a fully updated CentOS 7 system. Open the terminal app and type the following command:

sudo yum updateCode language: Bash (bash)

If there are any pending updates,ย install them. The result should be a fully up-to-date system with no packages waiting to be updated.

Step 3: Migrate CentOS 7 to Oracle Linux 8

Before we start, letโ€™s say a few words about the tool that will help us with the migration:ย ELevate. Designed by AlmaLinux, it supports migrations between major versions of Red Hat Enterprise Linux forks (Alma, Rocky, Oracle), allowing users to migrate from CentOS 7.x to 8.x versions of the RHEL derivative or upgrade from 8.x to 9.x within the same. For more information, visit theย projectโ€™s page.

Step 3.1: Install the ELevate Tool

The first step in the upgrade process is installing the โ€œelevate-releaseโ€ package on your current CentOS 7 system.

sudo yum install http://repo.almalinux.org/elevate/elevate-release-latest-el$(rpm --eval %rhel).noarch.rpmCode language: Bash (bash)
Install the ELevate Tool
Install the ELevate Tool

Step 3.2: Install Leapp and Migration Data

The migration process is based on a combination of Red Hatโ€™s Leapp, a tool designed to facilitate in-place upgrades of RHEL systems from one major version to another, and a community-created library containing the migration metadata set. So, letโ€™s install them:

sudo yum install leapp-upgrade leapp-data-oraclelinuxCode language: Bash (bash)
Install Leapp and Oracle's migration data.
Install Leapp and Oracle’s migration data.

When you run the above command, it will install more than 30 extra packages, mostly Python-related dependencies.ย Thisย isย completelyย expected. Also, youโ€™ll see a prompt asking you to accept the GPG key for Almaโ€™s ELevate repository. Just go ahead and accept it.

Step 3.3: Start Pre-Upgrade Checks

The next step is to start a pre-upgrade check. The command below verifies server compatibility without making any actual changes and creates a โ€œ/var/log/leapp/leapp-report.txtโ€ file that contains possible problems and recommended solutions:

sudo leapp preupgradeCode language: Bash (bash)

Most likely, some of the checks will fail, but there is no room for worry! Thatโ€™s normal because some tweaks are required in advance.

An error in the preliminary tests.
An error in the preliminary tests.

According to the official documentation, depending on the case, the three commands below solve the issue. In our case, this is the third command. No problem to run all three – do it.

sudo rmmod pata_acpi
echo PermitRootLogin yes | sudo tee -a /etc/ssh/sshd_config
sudo leapp answer --section remove_pam_pkcs11_module_check.confirm=TrueCode language: Bash (bash)

When you rerun the pre-upgrade check, youโ€™ll see a green report confirming everything is in order. This means youโ€™re all set to proceed safely with the upgrade.

sudo leapp preupgradeCode language: Bash (bash)
Pre-upgrade check succeeded.
Pre-upgrade check succeeded.

Step 3.4: Start the Actual Migration from CentOS 7 to Oracle Linux 8

Run the following command to migrate your CentOS 7 system to Oracle Linux 8.

sudo leapp upgradeCode language: Bash (bash)

Please be aware that upgrading can occasionally lead to errors if you are using packages from external repositories, such as EPEL. A common example is encountering an issue with the “openssl11-libs” package from the EPEL repo.

openssl11-libs error
openssl11-libs error

To fix this problem, uninstall the package by executing yum remove <package_name>. Afterward, rerun the sudo leap upgrade command, which should proceed without issues.

Moreover, nowโ€™s the perfect time to grab a coffee and settle in because, depending on your internet connection speed, the upgrade process will take some time.

Successful migration from CentOS 7 to Oracle Linux 8.
Successful migration from CentOS 7 to Oracle Linux 8.

Once the migration is completed, youโ€™ll be offered to reboot the system. Okay, the moment of truth!

sudo rebootCode language: Bash (bash)

After restart, youโ€™ll notice a new option called โ€œELevate-Upgrade-Initramfsโ€ pop up in theย GRUB menu. Your computer will pick it up automatically and start on its own in just a few moments.

GRUB bootloader.
GRUB bootloader.

Since the package upgrades involve a lot of background activity, the process might take a while. Please be patient if you cannot access the terminal to track these changes. Depending on your hardwareโ€™s capabilities and the number ofย packagesย being updated, it could take anywhere from a few minutes to half an hour.

Upgrading CentOS 7 to Oracle Linux 8.
Upgrading CentOS 7 to Oracle Linux 8.

In the final loop, the system will automatically reboot again, but this time, GRUB will display the entries for your Oracle Linux 8 system.

GRUB bootloader.
GRUB bootloader.

At this point, itโ€™s time to give yourself a big pat on the back because, just like that, youโ€™ve successfully transitioned your system from CentOS 7 to Oracle Linux 8. A big congrats from me as well!

Step 4: Check the OS Version (Optional)

To ensure everything goes according to plan, why not take a quick peek at theย OS version? In addition, you canย update the server hostnameย to match Oracle.

sudo hostnamectl set-hostname oracle8
sudo rebootCode language: Bash (bash)
cat /etc/oracle-releaseCode language: Bash (bash)
Successful migration from CentOS 7 to Oracle Linux 8.
Successful migration from CentOS 7 to Oracle Linux 8.

Post-Installation Steps

We recommend starting by removing the EPEL repository if youโ€™re using it. It still targets the older CentOS 7 and could lead to errors due to compatibility issues when you try to upgrade your system or install new packages. To remove it, execute:

sudo dnf remove epel-releaseCode language: Bash (bash)

Then, you can add it again. The installer will recognize that your system is RHEL 8 compatible and will install the appropriate EPEL 8 repository.

sudo dnf install epel-releaseCode language: Bash (bash)
Adding RHEL 8-compatible repo.
Adding RHEL 8-compatible repo.

Upgrade your system.

sudo dnf updateCode language: Bash (bash)
System update.
System update.

Remove all CentOS 7-related packages. To find them, run the command below:

sudo rpm -aq | grep el7Code language: Bash (bash)
Remove all CentOS 7-related packages
Remove all CentOS 7-related packages

Then open the “/etc/yum.conf” file and comment out the “exclude” line shown below.

sudo nano /etc/yum.confCode language: Bash (bash)
Edit the "yum.conf" file.
Edit the “yum.conf” file.

Finally, to remove them, list them individually as arguments to the dnf remove command. In our case, it looks like this:

Remove all CentOS 7-related packages.
Remove all CentOS 7-related packages.

For a more in-depth introduction to the DNF command, we highly recommend consulting our article on the subject, “DNF Command-Line Package Manager in Linux: A Complete Guide.”

Conclusion

As outlined in this comprehensive guide, the migration from CentOS 7 to Oracle Linux 8 provides a strategic upgrade path in light of CentOS 7 reaching its end of life on June 30, 2024.

Users can confidently transition to a more contemporary and supported version of Oracle Linux by meticulously following the steps provided. For more information, see the Oracleโ€™s documentation.

I try to make this guide as simple as possible. Thanks for using it! Please share your thoughts in the comments box below.

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Think You're an Ubuntu Expert? Let's Find Out!

Put your knowledge to the test in our lightning-fast Ubuntu quiz!
Ten questions to challenge yourself to see if you're a Linux legend or just a penguin in the making.

1 / 10

Ubuntu is an ancient African word that means:

2 / 10

Who is the Ubuntu's founder?

3 / 10

What year was the first official Ubuntu release?

4 / 10

What does the Ubuntu logo symbolize?

5 / 10

What package format does Ubuntu use for installing software?

6 / 10

When are Ubuntu's LTS versions released?

7 / 10

What is Unity?

8 / 10

What are Ubuntu versions named after?

9 / 10

What's Ubuntu Core?

10 / 10

Which Ubuntu version is Snap introduced?

The average score is 68%