Migrate RHEL7 to CentOS7

A migration from RHEL7 to CentOS7 could be something that is needed in certain cases. While re-installing the OS and tranferring your files and settings is not undoable, it creates a lot of effort and possible chance for downtime. Therefor it’s much more handy when an in-place migration between the two can be done. CentOS uses the same package-source as RHEL and tries to be as close as it can be to Red Hat with their distribution. It’s basically RHEL without logo’s, support and licensing.

A good reason to do such migrations is when you want to legally and without limitations  use a clone of a system that is running RHEL. For example to do some testing or as a staging platform for your production environment.

At this time, CentOS 7 has just been released so there isn’t a lot of information available regarding the topic but by using instructions from previous releases, it’s doable :)

We will start with a standard RHEL7 installation:

rhel7tocentos7_before1

To migrate this system to CentOS, we need to perform the following steps:

Check the currently installed version/release:

Check which RHEL-related packages are installed:

Remove some of the above packages and dependencies with yum:

Manually uninstall the rest to not have issues with dependencies:

After these steps, verify if everything has been removed:

Delete some folders to prevent problems with message  cpio: rename failed – Is a directory when installing centos-release:

Download the CentOS GPG-key and package replacements for the previously removed packages:

Install the GPG-key:

Install the download packages:

Put yum in a clean, updated state:

Update the GRUB2-config to include the new information:

Reboot your system:

During and after the reboot, you should have a CentOS-system :)

rhel7tocentos7_after1

To be sure, we can check the release-information:

The above steps should be all that is needed to convert RHEL7 to CentOS7. The other way around probably works in about the same way.
rhel7tocentos7_before2becomes:

rhel7tocentos7_after2

12 thoughts on “Migrate RHEL7 to CentOS7

  1. Hi,

    Your tutorial is interesting but some parts of it are truncated (mainly the curl commands retrieving packages from the buildlogs.centos.org repository.
    It is still possible to get the package names but through page code inspection!
    Can you update your html code?

    Thanks.

    • I updated the graphical part a little but seems that I will need to look for a better suiting theme in order to display terminal output in a neat way :)

      Thanks for your remark.

  2. Interesting tutorial indeed. But you need to look at some of your code; [root@localhost ~]# mkdir tmp && cd tmp
    Probably it has been mixed up by some html editor?

    • This code is as it is intended to be…
      That command creates a directory and if it’s created succesfully, it cd’s into that new dir.
      It would be the same to write:
      [root@localhost ~]# mkdir tmp
      [root@localhost ~]# cd tmp

  3. # yum clean all
    Loaded plugins: changelog, fastestmirror, product-id, subscription-manager
    This system is registered to Red Hat Subscription Management, but is not receiving updates. You can use subscription-manager to assign subscriptions.
    Cleaning up everything

    # locate subscription-manager
    # rpm -e –nodeps subscription-manager
    # yum clean all
    Loaded plugins: changelog, fastestmirror
    Cleaning up everything

  4. I purchased a self-maintenance license and I have found it more convenient to strip out the RHN stuff and just go with CentOS than it is to deal with the registration and subscription process. Go figure!

    Great post, thanks a lot.

  5. Exactly the recipe I needed! Got handed a brand-new RHEL7 installation (unregistered) and couldn’t install most of the packages I needed for the development work. After trying a bunch of work-arounds (only 50% of which worked-around), I decided to migrate to CentOS 7. 15 minutes later and now EVERYTHING I need is working perfectly.

    THANK YOU for posting this!
    Ken

  6. THis doc worked great for me. I followed it to convert Oracle Linux to CentOS. I face problem but that was only because some of the oracle linux packages were not removed before I tried yum install for centOS packages.

  7. Seems to have worked OK, except that PRETTY_NAME stayed “Red Hat …” and the boot menu still lists the kernels as Red Hat ones (even after editing the PRETTY_NAMES definition and running grub2-mkconfig.

    • I’m getting the same thing here after converting a “more maximal” build of RHEL7 into a CentOS7 box. Interestingly, a minimal RHEL7 VM converted to CentOS7 *does not* suffer from the same oddity, which probably accounts for what jensd sees in the original post.

      Like you, I changed PRETTY_NAME back to “CentOS Linux 7 (Core)” from “Red Hat Enterprise Linux” in /etc/os-release and re-ran the grub mkconfig tool. I reinstalled the centos-release package a few times as well too, which wrote the right thing, but on each reboot the /etc/os-release file gets regenerated by something I can’t identify. This doesn’t happen on the minimal migrated box.

      pastebin.centos.org 73281 (dunno if links work)

      The #systemd cabal [TINC] on IRC deny that it’s their offering that’s recreating this file, so I guess it’s some lingering chunk of RHEL that I can’t identify. os-release is really a file, not a symlink, so it’s not the tmpfiles.d snippet doing a bad thing.

      Making /etc/default/grub’s GRUB_DISTRIBUTOR like a fresh minimal CentOS7 install or that on the converted minimal CentOS7 box gave no relief.

      Anyone have any bright ideas about what’s really happening here?

Leave a Reply

Your email address will not be published. Required fields are marked *