Home Oracle Linux How To Migrate CentOS Linux To Oracle Linux

How To Migrate CentOS Linux To Oracle Linux

By sk
Published: Last Updated on 7.6K views

Oracle Linux is a RHEL-based Linux distribution developed by Oracle. It is one of the best alternative to CentOS Linux. This guide explains how to migrate CentOS Linux to Oracle Linux using centos2ol script.

Introduction

After CentOS Community Manager Rich Bowen announced that they are shifting focus from CentOS Linux to CentOS Stream, there is a great resentment among developers and users.

Many users strongly condemns this decision. However, the decision is already made and it seems that there is no going back.

Since CentOS Stream is a rolling preview (i.e. development), a lot of users raised their concern about its stability.

At the moment, the stable and viable RHEL-based alternatives to CentOS are AlmaLinux, Rocky Linux and Oracle Linux. If you'd like to migrate CentOS Linux to Oracle Linux, this tutorial will teach you how.

Centos2ol (CentOS To Oracle Linux) script

The Oracle development team has created a script called "centos2ol.sh" to convert your CentOS 8, 7 and 6 systems to Oracle Linux.

Centos2ol script has the following two main functions:

  • It switches CentOS system's yum configuration to use the Oracle Linux yum server to update some core packages.
  • It installs the latest Oracle Unbreakable Enterprise Kernel (UEK).

That's it! You don't even need to restart the system after switching. However, if you want to take advantage of UEK, reboot your system and log in to Oracle Linux kernel.

A word of caution:

I used this script to migrate CentOS 7 to Oracle Linux 7. The transition was not successful at the first time. However, I got lucky at the second attempt. I do not recommend this script in production. Because, it broke my CentOS 7 server at first attempt and the server didn't boot. Luckily, it was just a testing VM and I simply reinstalled it. So I can't guarantee that this script will convert CentOS to Oracle Linux without any issues. YOU HAVE BEEN WARNED!

Let us begin the migration.

Migrate CentOS Linux To Oracle Linux

Step 1: First of all, backup your important data, just in case.

Step 2: Then, update your CentOS 7 system to most recent version:

$ sudo dnf update

On CentOS 6, run this command to update it:

$ sudo yum update

Step 3: After updating your system, reboot it.

$ sudo reboot

Let us check the CentOS 7 version:

$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
Check centos release version
Check centos release version

Step 4: Next, make sure you have installed Python 2.x, which is required by centos2ol script. If python2 is not available, you may get the following output:

Checking for required packages...
'python2' command not found. Please install or add it to your PATH and try again.
For assistance, please email <oraclelinux-info_ww_grp@oracle.com>.

To install Python2, simply run:

$ sudo dnf install python2

Or,

$ sudo yum install python2

Step 5: Download the centos2ol.sh script:

$ curl -O https://linux.oracle.com/switch/centos2ol.sh

Or, download it from GitHub:

$ curl -O https://raw.githubusercontent.com/oracle/centos2ol/main/centos2ol.sh

Step 6: Run centos2ol script as root or sudo user to migrate CentOS Linux to Oracle Linux:

$ sudo sh centos2ol.sh

Or,

$ sudo bash centos2ol.sh

Now the Oracle Linux migration process will start. The centos2ol script will backup the existing CentOS repository files, add Oracle Linux repositories, replace centos logos with oracle logos, update a few core packages and install the latest Oracle Unbreakable Enterprise Kernel.

All of these are fully automated. Just run the script and sit back!

Migrate CentOS Linux To Oracle Linux
Migrate CentOS Linux To Oracle Linux

This will take a while depending upon the speed of your Internet connection. Please be patient.

The switch was successful but with a few Python package errors.

[...]
Error: Package: python2-dnf-plugins-core-4.0.2.2-3.el7_6.noarch (@extras/7)
           Requires: python2-hawkey >= 0.7.0
           Removing: python2-hawkey-0.22.5-2.el7_9.x86_64 (installed)
               python2-hawkey = 0.22.5-2.el7_9
           Downgraded By: python2-hawkey-0.6.3-4.el7.x86_64 (ol7_latest)
               python2-hawkey = 0.6.3-4.el7
Error: Package: python2-dnf-4.0.9.2-1.el7_6.noarch (@extras/7)
           Requires: python2-hawkey >= 0.22.5
           Removing: python2-hawkey-0.22.5-2.el7_9.x86_64 (installed)
               python2-hawkey = 0.22.5-2.el7_9
           Downgraded By: python2-hawkey-0.6.3-4.el7.x86_64 (ol7_latest)
               python2-hawkey = 0.6.3-4.el7
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
Could not automatically sync with Oracle Linux repositories.
Check the output of 'yum distro-sync' to manually resolve the issue.
For assistance, please email <oraclelinux-info_ww_grp@oracle.com>.

Step 7: Run the following command to synchronize installed packages to the latest available versions.

$ sudo yum distro-sync

I kept receiving the same python package errors as before. I couldn't figure out how to solve. So I ignored this message and restarted the system.

Good lord! It worked! I can see that the Grub is updated with Oracle Linux entry.

Oracle Linux boot menu
Oracle Linux boot menu

After logging into the newly converted Oracle Linux 7 system, I checked the distribution version and Kernel details to verify if Oracle Linux migration is successful:

$ cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.9 (Maipo)
$ uname -r
5.4.17-2036.100.6.1.el7uek.x86_64
Oracle Linux Server 7.9
Oracle Linux Server 7.9

Yes, it is! I have successfully converted CentOS Linux 7 to Oracle Linux 7.

Step 8: Change the hostname of Oracle Linux 7:

# systemctl set-hostname ol7

Log out and log back in to apply the changes. Now everything is perfect!

Oracle Linux Server 7
Oracle Linux Server 7

Hope this helps.

Resources:

You May Also Like

11 comments

Scott Dowdle December 14, 2020 - 10:03 pm

Doesn’t seem to work on CentOS 8.3… and says the distro isn’t supported.

Reply
Ben Wagner January 11, 2021 - 1:27 pm

You can try this on Centos7 Upgrade to Oracle Linux:
yum remove dnf python-hawkey

then
yum distr-sync

finally
package-cleanup –oldkernels –count=1

Then the system is now up2date. Unfortunately dnf is not there anymore, but now we can continue to upgrade to Oracle Linux 8 where dnf is default.

Reply
sk January 11, 2021 - 5:20 pm

Thank you.

Reply
Tony January 14, 2021 - 9:50 pm

How to upgrade from CentOS 6.10 to Oracle Linux 7.9 … does the script mentioned in this article do that? If not, what is the process? And is Oracle Enterprise Linux (and regular updates) free or do you have to get support to get the updates?

Reply
sk January 15, 2021 - 12:06 pm

You must first upgrade to CentOS 7.9 and then convert it to Oracle Linux 7.9.

Reply
Tom November 19, 2021 - 3:01 am

When running the script on CentOS 6.10, will it migrate to Oracle Linux 6? And if so, for how long will Oracle provide security patches at no cost on Oracle Linux 6?

Reply
sk November 19, 2021 - 11:48 am

>> When running the script on CentOS 6.10, will it migrate to Oracle Linux 6
Yes it, will.

>> how long will Oracle provide security patches at no cost on Oracle Linux 6?
I don’t know for sure. Please check the Oracle Linux website.

Reply
Tom November 19, 2021 - 8:35 pm

I’ve looked high and low on the Oracle website but cannot find info as to when patches end for any of their versions of Linux for users who do not pay for support. They’ve posted this document (link below), which shows dates for “Extended Support” for version 6 (and others), but it does not explain if this means security patches for systems without a paid support contract. For CentOS users looking to switch to Ubuntu or Oracle or some other version of Linux with “free” patches, we need to know this information. https://www.oracle.com/us/support/library/elsp-lifetime-069338.pdf

Reply
sk November 19, 2021 - 8:59 pm

Yes, I got the same link. I couldn’t find any reliable information on Oracle site. It is better to upgrade to latest Oracle Linux or migrate from Oracle Linux to AlmaLinux or Rocky Linux. https://ostechnix.com/migrate-centos-7-to-almalinux-8-centos-8-rocky-linux-8/

Reply
Tom November 19, 2021 - 9:51 pm

Thanks for this great information! What is the best way to get from CentOS 6 to some form of version 7 or 8? Would it be best to migrate from CentOS 6 to Oracle Linux 6 (using the centos2ol.sh script), then upgrade to Oracle Linux 7 or Oracle Linux 8 from there?

Reply
sk November 19, 2021 - 10:45 pm

>> Would it be best to migrate from CentOS 6 to Oracle Linux 6 (using the centos2ol.sh script), then upgrade to Oracle Linux 7 or Oracle Linux 8 from there?

This would be best.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

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

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More