A Bridge to the Cloud...

Switching from CentOS to Oracle Linux: a hands-on example

Simon Coter, and Avi Miller

On December 8 via the CentOS blog, Red Hat announced that CentOS Linux 8 would reach end-of-life in December 2021, which is eight years before the upstream distribution on which it is based and the original expected EOL date. From January 2022, the only release provided by the CentOS project will be the CentOS Stream which is positioned upstream of Red Hat Enterprise Linux (RHEL) after Fedora. This means that CentOS will no longer be a drop-in replacement for RHEL.

So, while CentOS Linux 7 will follow its current life cycle and be maintained, anyone currently using CentOS Linux 8 as a drop-in RHEL replacement have to decide whether to switch to CentOS Stream (and thus lose 1:1 compatibility with RHEL, which has implications for development and test environments) or switch to RHEL which requires paid support subscriptions.

We think there is a much simpler third option: switch to Oracle Linux instead. We published a blog post earlier this week that explains why, but here is the TL;DR version:

  • Oracle Linux is free to download, distribute and use (even in production) and has been since its release over 14 years ago
  • Installation media, updates and source code are all publicly available on the Oracle Linux yum server with no login or authentication requirements
  • Since its first release in 2006, Oracle Linux has been 100% application binary compatible with the equivalent RHEL version. In that time, we have never had a compatibility bug logged.

For these reasons, we created a simple script to allow users to switch from CentOS to Oracle Linux about five years ago. This week, we moved the script to GitHub to allow members of the CentOS community to help us improve and extend the script to cover more CentOS respins and use cases.

The script can switch CentOS Linux 6, 7 or 8 to the equivalent version of Oracle Linux. Let's take a look at just how simple the process is.

Download the centos2ol.sh script from GitHub

The simplest way to get the script is to use curl:

$ curl -O https://raw.githubusercontent.com/oracle/centos2ol/main/centos2ol.sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 10747 100 10747 0 0 31241 0 --:--:-- --:--:-- --:--:-- 31241

If you have git installed, you could clone the git repository from GitHub instead.

Run the centos2ol.sh script to switch to Oracle Linux

To switch to Oracle Linux, just run the script as root using sudo:

$ sudo bash centos2ol.sh

Sample output of script run.

As part of the process, the default kernel is switched to the latest release of Oracle's Unbreakable Enterprise Kernel (UEK) to enable extensive performance and scalability improvements to the process scheduler, memory management, file systems, and the networking stack. We also replace the existing CentOS kernel with the equivalent Red Hat Compatible Kernel (RHCK) which may be required by any specific hardware or application that has imposed strict kernel version restrictions.

Switching the default kernel (optional)

Once the switch is complete, but before rebooting, the default kernel can be changed back to the RHCK. First, use grubby to list all installed kernels:

[demo@c8switch ~]$ sudo grubby --info=ALL | grep ^kernel
[sudo] password for demo:

In the output above, the first entry (index 0) is UEK R6, based on the mainline kernel version 5.4. The second kernel is the updated RHCK (Red Hat Compatible Kernel) installed by the switch process while the third one is the kernel that were installed by CentOS and the final entry is the rescue kernel.

Next, use grubby to verify that UEK is currently the default boot option:

[demo@c8switch ~]$ sudo grubby --default-kernel

To replace the default kernel, you need to specify either the path to its vmlinuz file or its index. Use grubby to get that information for the replacement:

[demo@c8switch ~]$ sudo grubby --info /boot/vmlinuz-4.18.0-240.1.1.el8_3.x86_64
args="ro crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet $tuned_params"
initrd="/boot/initramfs-4.18.0-240.1.1.el8_3.x86_64.img $tuned_initrd"
title="Oracle Linux Server (4.18.0-240.1.1.el8_3.x86_64) 8.3"

Finally, use grubby to change the default kernel, either by providing the vmlinuz path:

[demo@c8switch ~]$ sudo grubby --set-default /boot/vmlinuz-4.18.0-240.1.1.el8_3.x86_64
The default is /boot/loader/entries/0dbb9b2f3c2744779c72a28071755366-4.18.0-240.1.1.el8_3.x86_64.conf with index 1 and kernel /boot/vmlinuz-4.18.0-240.1.1.el8_3.x86_64

Or its index:

[demo@c8switch ~]$ sudo grubby --set-default-index 1
The default is /boot/loader/entries/0dbb9b2f3c2744779c72a28071755366-4.18.0-240.1.1.el8_3.x86_64.conf with index 1 and kernel /boot/vmlinuz-4.18.0-240.1.1.el8_3.x86_64

Changing the default kernel can be done at any time, so we encourage you to take UEK for a spin before switching back.

It’s easy to access, try it out.

For more information visit oracle.com/linux.

Join the discussion

Comments ( 7 )
  • likbez Wednesday, December 30, 2020
    Thank you for writing this script. It is very useful. It can be enhanced along the lines suggested at http://www.softpanorama.org/Commercial_linuxes/Oracle_linux/conversion_of_centos_to_oracle_linux.shtml

    Happy New Year for you and your families !!!
  • Simon Wednesday, December 30, 2020
    Hi Likbez,

    you can submit your enhancements on GitHub, where the script is hosted.

  • Jeremy Ruffer Thursday, January 28, 2021
    I found that I had no network interface when booting UEK.
    Booting the RHCK was fine.
    I suspect that my network card is incompatible with UEK
  • Simon Thursday, January 28, 2021
    Hi Jeremy,

    it seems really weird that a driver is missing in UEK.
    I'm (instead) thinking to a possible device-name change and/or NetworkManager not enabling it.
    BTW, feel free to open an issue on GitHub and we'll be glad to help.

  • Tony Esposito Sunday, February 28, 2021
    Going from CentOS 7 to OEL 7, I do not see a UEK when I do:
    grubby --info=ALL
    I do see a Linux 7.x kernel and it is set to be my default kernel.
    Is this an indication of a problem (the missing UEK)?
  • Brian Little Friday, April 2, 2021
    Has this been tested by anyone on an AWS EC2 Instance?
  • Simon Friday, April 2, 2021
    Hi Brian,

    we do not directly run OL on AWS but our images are also available there.
    That said, feel free to get it tested (if you can) to then report your feedback on our GitHub repo.

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.