How to convert CentOS Linux to Red Hat Enterprise Linux on Azure
Published Oct 30 2023 04:43 PM 13.7K Views
Microsoft

This blog has been co-authored by Campbell Vertesi, Microsoft Partner CTO for Red Hat.

 

Revision (March 13, 2024): Step 7 listed below pertaining to Azure Hybrid Benefit for Linux CLI is relevant for custom CentOS images and not marketplace images.

 

In an ever-evolving world of cloud computing, businesses are constantly seeking ways to optimize their operations, enhance security, and reduce costs. Microsoft Azure has been at the forefront of providing innovative solutions to cater to these demands. The recent addition of "Red Hat Enterprise Linux (RHEL) for Third-Party Linux Migration with Extended Life Cycle Support (ELS)" to the Azure Marketplace is an exciting development that promises to make migrations and operations even more efficient and cost-effective.

 

Red Hat Enterprise Linux is renowned for its stability, security, and performance. It has been a go-to choice for many enterprises, especially when it comes to mission-critical workloads. Azure's integration with RHEL through the Azure Marketplace listing extends the benefits of this powerful operating system to Azure users. 

 

The new offering includes Red Hat Enterprise Linux, the convert2RHEL tool, and Extended Life Cycle Support, which is a game-changer for businesses using CentOS 7. It ensures that organizations that rely on this version can use the convert2RHEL utility, developed by Red Hat, to convert a CentOS 7.9 instance in-place to a RHEL 7.9 instance. Once converted, they can continue to receive critical security patches and updates for an extended period.  

 

Organizations that use CentOS Linuxa freely available, community-supported Linux distributioncurrently face a choice. The CentOS Project will discontinue updates and releases of CentOS Linux 7 on June 30, 2024. As a result, CentOS Linux users must migrate to a new operating system (OS) to continue receiving updates, patches, and new features.

 

Redeploy or convert?

The first decision you will have to make is whether to re-deploy your workloads onto RHEL, or convert each system. If you are managing the content of your VMs with tools like Ansible or Packer, in many cases you can reuse your existing playbooks or configurations based on the matching RHEL version, with only minimal changes. By redeploying based on the Azure Marketplace images, you ensure you get clean systems with the full array of benefits that RHEL on Azure can bring.

 

Red Hat Subscriptions

Red Hat Enterprise Linux is a production-grade Linux distribution, which offers access to its repositories and to the convert2RHEL tool to subscribers. On Azure you have the choice of running your RHEL VMs with subscriptions purchased through Red Hat (Bring Your Own Subscription or BYOS) or with a Pay-As-You-Go (PAYG) subscription billed through Azure. Although PAYG is more convenient for most users, the convert2RHEL tool only supports BYOS for the conversion process. Fortunately, it is easy to convert from BYOS to PAYG on Azure (see step 7!). 

 

Before you start, make sure you have at least one subscription on hand. For development teams within organizations already using other Red Hat technologies, Red Hat offers  Red Hat Developer Subscription for Teams that provides a no-cost subscription for development purposes, enabling you to develop and deploy applications on a consistent platform to reduce the risk of problems when moving to production. This is a great option and can be switched to PAYG if moved into a production environment.

 

How to convert a single machine

It is not complicated to convert from CentOS to equivalent RHEL on a single VM instance. Red Hat provides the convert2RHEL tool to make the process as simple as possible. It scans your VM for incompatibilities and potential problems before making any changes, and gives you plenty of warning to make fixes before automatically converting the system.

The official documentation of Convert2RHEL from Red Hat is comprehensive. In this post, we’ll walk you through the most common scenario for converting to RHEL on Azure. Feel free to check the documentation if your environment differs at all.

 

1) Backup the VM

You are about to make critical, irreversible changes to this VM! Take a backup first. The easiest way is using the Azure Backup service, which provides isolated backups in a vault with built-in management, optimization, and scaling. Not to mention easy restore! You can follow the standard instructions for backing up a single VM with Azure Backup.

 

2) Update the VM

Convert2RHEL requires that the CentOS environment is fully up to date. There are no special steps required here, just the usual

sudo yum –y update

and reboot if necessary. Note that convert2RHEL will complain if you’re not running the most recent kernel version, so you will likely need that reboot.

 

3) Install Red Hat official keys and the convert2RHEL repo

In order to install convert2RHEL, you need to configure its package repository and the official Red Hat signing keys.

 

sudo curl -o /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release https://www.redhat.com/security/data/fd431d51.txt
sudo curl -o /etc/yum.repos.d/convert2rhel.repo https://ftp.redhat.com/redhat/convert2rhel/7/convert2rhel.repo

 

4) Install and configure convert2RHEL

Installing convert2RHEL is as easy as `yum`, and configuration is basically just putting your subscription details into an .ini file. Though it’s possible to pass subscription information in arguments when you start the convert2RHEL process, that puts you at risk of leaking credentials through the process list and command history. It’s safer to put the values in a protected file.

 

sudo yum -y install convert2rhel
sudo vi /etc/convert2rhel.ini

The `convert2rhel.ini`file is very simple. If you’re using Subscription Manager (recommended!) it will look like this:

 

[subscription_manager]
org = <organization_ID>
activation_key = <activation_key>

 

If you want to just provide your Red Hat username and password, you can do that too:

 

[subscription_manager]
username = <username>
password = <password>

 

5) Convert the VM

Now you are ready to run the actual conversion!

 

sudo convert2rhel 

 

The convert2RHEL process explains everything as it happens. It will scan your environment and warn you about anything that might break the conversion, or which would be unsupported by Red Hat. For example, many use external repositories like Remi to get modern package versions for CentOS 7. Though most of the time they work just fine, packages from those third-party repos aren’t supported by Red Hat, and convert2RHEL will warn you about them.

After all the pre-checks are complete, you will be offered a final confirmation before making the irreversible changes to your system. When the process completes, the tool will recommend a reboot (`sudo reboot now`) so you can start running the official Red Hat kernel, and you’re done with the conversion!

 

  6) Review and remove third party packages that don't have a RHEL component

To ensure you aren’t accidentally running any left over 3rd party software, remove third-party packages from the original OS that remained unchanged. These are typically packages that do not have a RHEL counterpart. To get a list of these packages, use:

 

yum list extras --disablerepo="*" --enablerepo=<RHEL_RepoID>

 Replace RHEL_RepoID with your repository.

 

 7) Tell Azure this is a RHEL system

Azure has many built-in benefits for RHEL VMs, and works to ensure the best possible experience for Red Hat users.  To avail these benefits, you must mark the VM as RHEL in a way that Azure understands, by installing the “Azure Hybrid Benefit” VM extension. This extension has no performance or other impact on your machine, but it allows you to change subscription types, switch between Pay-As-You-Go and BYOS, and add support packages at any time.

The easiest way to install the extension is from the Azure CLI on a machine that is authorized to modify the converted VM. It’s a simple two-command process to first install the extension:

 

az vm extension set \

    --resource-group $resource_group \

    --vm-name $vm_name \

    --publisher Microsoft.Azure.AzureHybridBenefit \

    --name AHBForRHEL

 

And then choose your license, in this case either RHEL_BASE (for PAYG) or RHEL_BYOS.

 

az vm update \

    --resource-group $resource_group \

    --set tags.licensePrivateOfferId=$offer_id \

    --name $vm_name \

    --license-type RHEL_BYOS

 

Note that if you don’t explicitly set RHEL_BYOS, Pay-As-You-Go is the default! That second step is very important to ensure you don’t double-pay for your subscription.

 

8) (Optional) Install Red Hat Insights

Red Hat Insights is a service included in your subscription, which continuously analyzes platforms and applications to predict risk, recommend actions and analyze costs to help you better manage IT spending and your hybrid cloud environments. We definitely recommend installing and enabling its’ agent to take advantage of these capabilities.

 

sudo yum install –y insights-client
sudo insights-client --register

 

Once your system is registered with Insights, make sure it appears in your Red Hat console under Red Hat Insights > Inventory > Systems .

 

9) Celebrate

You’re done! Convert2RHEL did a lot of work for you, so take a breather and celebrate your victory.

If you face an issue while performing Convert2RHEL, please refer to the article How do I open and manage a support case on the Customer Portal? in order to obtain support from Red Hat.

 

Azure's robust ecosystem provides you with the flexibility to scale resources up or down as needed, allowing you to align your infrastructure with your business requirements. Whether you're considering migrating to the cloud or looking to enhance your existing cloud environment, this offering opens up new possibilities and ensures that you can continue to leverage the power of RHEL in an Azure ecosystem.

Co-Authors
Version history
Last update:
‎Mar 13 2024 05:35 PM
Updated by: