As discussed in part 1 of the blog, How to migrate from RHEL 7.4 to CentOS 7.4, one of the biggest “selling” points for CentOS is that CentOS is built from the official Red Hat source code. This means that CentOS and RHEL are incredibly, if not entirely, compatible.

In this post, I’m going to use the CentOS Migration Guide, updated for the CentOS 7.4 release, to convert a vanilla RHEL 7.4 installation to CentOS 7.4.

A real migration in action

As always, there are risks associated with any system-level change, so we recommend taking a backup of the system immediately prior to attempting the migration, just in case something does go wrong and the system needs to be restored to its present state. We also recommend testing the migration procedure on non-production systems first so that issues can be caught and remedied prior to migrating your production environment. It’s also wise to schedule a larger maintenance window than you think you’ll need to provide an additional buffer in case there are issues in production that were not encountered in non-production.

CentOS provides a Migration Guide online. One more word of caution regarding this Migration Guide is that this document, and therefore the listed package versions, are not necessarily up-to-date. For instance, you would probably need to update the URLs for the centos-release, centos-release-notes, centos-indexhtml, redhat-logos, yum and yum-plugin-fastestmirror packages for these instructions to work.

System migration is ultimately performed via the ‘yum upgrade’ command (CentOS packages have a higher versioning than the same package in RHEL) so not only will your system be migrated, it will be updated simultaneously!

Let’s verify that we’re on a RHEL 7.4 system (you can click to expand all images):

Yup… RHEL 7.4.

Now, let’s create a temp directory to work inside of:

Let’s make sure that we’ve separated ourselves from the Red Hat Network, that we won’t be using abrt to report crashes to bugzilla.redhat.com and remove any Red Hat release notes (there were some warnings on my system, due to being a very minimal install, that I’ve excluded for brevity):

We now need to remove the Red Hat release and indexhtml packages, if they’re installed:

On some systems, the /usr/share/redhat-release or /usr/share/doc/redhat-release directories may be left, but empty, so we’ll remove it so that it doesn’t cause issues with installing the centos-release package:

We now download the RPMs that will repoint the yum package manager towards the CentOS mirrors:

Install these RPMs:

Let’s clean up yum. We’re primarily interested in purging any cached Red Hat package data so we can repopulate the cache with CentOS data:

Now let’s repopulate the yum cache:

Finally, we’ll perform the upgrade using yum. This generates a lot of output for each package being updated so we’ll just show the beginning and end of the sequence here.

Finally, we’ll verify that we’re running CentOS 7.4:

Congratulations! Our system is now running CentOS 7.4!

At this point, if this were a real system, we should reboot and verify that all of our daemons and services are running as expected.

What could we do if we have a system running an older version of RHEL?

Let’s say we have a system that was stuck on RHEL 7.1 because our support contract ran out. Let’s also say that we want to update to CentOS 7.4. We can do that easily, too! What we’d do is download the CentOS 7.1 RPMs (from vault.centos.org since they are not currently available on the CentOS mirrors) and then perform the installs and updates. This will leave us with a CentOS 7.4 system after the update:

BOOM! Our RHEL 7.1 system is now a CentOS 7.4 system, complete with all available updates!

Next steps

About the Author:
Rich Alloway

Rich has over 19 years of experience in the IT industry specializing in CentOS-based and OpenWRT-based Linux systems, and microwave point-to-point and point-to-multipoint RF engineering. Rich holds a degree in computer science and is a certified master Linux administrator as well as a certified Aperto technician.