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:


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

Check the currently installed version/release:

[root@localhost ~]# cat /etc/*release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.0 (Maipo)"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.0 (Maipo)"
REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
Red Hat Enterprise Linux Server release 7.0 (Maipo)
Red Hat Enterprise Linux Server release 7.0 (Maipo)

Check which RHEL-related packages are installed:

[root@localhost ~]# rpm -qa|egrep "rhn|redhat"

Remove some of the above packages and dependencies with yum:

[root@localhost ~]# yum remove rhnlib redhat-support-tool redhat-support-lib-python

Manually uninstall the rest to not have issues with dependencies:

[root@localhost ~]# rpm -e --nodeps redhat-release-server
[root@localhost ~]# rpm -e --nodeps redhat-logos
[root@localhost ~]# rpm -e --nodeps yum

After these steps, verify if everything has been removed:

[root@localhost ~]# rpm -qa|egrep -i "rhn|redhat"
[root@localhost ~]#

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

[root@localhost ~]# rm -rf /usr/share/doc/redhat-release/
[root@localhost ~]# rm -rf /usr/share/redhat-release/

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

[root@localhost ~]# mkdir tmp && cd tmp
[root@localhost tmp]# curl -O http://mirror.centos.org/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7
[root@localhost tmp]# curl -O http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-24.el7.noarch.rpm
[root@localhost tmp]# curl -O http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-3.4.3-118.el7.centos.noarch.rpm
[root@localhost tmp]# curl -O http://mirror.centos.org/centos/7/os/x86_64/Packages/centos-logos-70.0.6-1.el7.centos.noarch.rpm
[root@localhost tmp]# curl -O http://mirror.centos.org/centos/7/os/x86_64/Packages/centos-release-7-0.1406.el7.centos.2.3.x86_64.rpm

Install the GPG-key:

[root@localhost tmp]# rpm --import RPM-GPG-KEY-CentOS-7

Install the download packages:

[root@localhost tmp]# rpm -Uvh *.rpm

Put yum in a clean, updated state:

[root@localhost tmp]# yum clean all
[root@localhost tmp]# yum upgrade

Update the GRUB2-config to include the new information:

[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg

Reboot your system:

[root@localhost ~]# sudo init 6

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


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

[root@localhost ~]# cat /etc/*release
CentOS Linux release 7.0.1406 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID_LIKE="rhel fedora"
PRETTY_NAME="CentOS Linux 7 (Core)"
CentOS Linux release 7.0.1406 (Core)
CentOS Linux release 7.0.1406 (Core)

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.


18 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?


    • 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

      • Jensd, please consider viewing your page again. The ampersands are not displaying properly and the are printing the literal “html code” instead of the symbols:

        [root@localhost ~]# mkdir tmp && 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!

  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?

      • try to remove remove /var/lib/rhsm/branded_name or whole dir /var/lib/rhsm , then remove /etc/os-release , reinstall centos-release… there could leftovers in /etc/pki/product/*pem … ofcourse first make backup of those :)

        looks like /usr/libexec/initscripts/brandbot is updating os-release file if branded_name file exists

      • I had the same problem recently.

        what I did is to:
        – remove subscription-manager package
        – rename /var/lib/rhsm to /var/lib/rhsm_ or something else
        – replace PRETTY_NAME=”Red Hat Enterprise Linux” with PRETTY_NAME=”CentOS Linux 7 (Core)” in /etc/os-release
        – recreate initramfs using dracut -f

        I hope it works for you too.

  8. Hi, I have tried to attempt this and used neofetch to check the system settings and it shows that the pc goes from RHEL 6 to CentOS6 but im using a vm and when I reboot my system the mount points I have fail to mount. I have one mount point that points to a backup network drive and the other is the OS. Is there anything to check on the HDD before rebooting after making these changes?

Leave a Reply

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