RedHat to CentOS Server Conversion

RedHat Enterprise Linux is a great OS, but it does have some expense associated with it in terms of update entitlements. In some cases, it may be acceptable to use CentOS Linux instead. From the CentOS website:

The CentOS Linux distribution is a stable, predictable, manageable and reproducible platform derived from the sources of Red Hat Enterprise Linux (RHEL). Since March 2004, CentOS Linux has been a community-supported distribution derived from sources freely provided to the public by Red Hat. As such, CentOS Linux aims to be functionally compatible with RHEL. We mainly change packages to remove upstream vendor branding and artwork. CentOS Linux is no-cost and free to redistribute.

There are many articles which cover, in lesser or greater detail, the process of converting a running server from RedHat to CentOS. The process described here was tested and was found to work for the particular servers I work with. YMMV, as they used to say on UseNet…


Prepare the Server and Download CentOS Packages

Login to the server and become root. Ideally, you should do a yum upgrade as a first step to get all packages up to the latest versions. This may not be possible in some circumstances, the steps below have been tested on a server where the outstanding updates were not applied first and there didn’t seem to be any adverse effect. Nonetheless, patching your servers is a Good Thing™ and is to be encouraged.

Create a temporary working area

# mkdir -p /home/temp/centos
# cd /home/temp/centos

Verify your version of RHEL, these instructions apply only to v6.

# cat /etc/redhat-release

Determine your architecture (32-bit = i386/i686, 64-bit = x86_64)

# uname -i

Download (wget) the applicable package files for your release and architecture.

The version numbers on these packages will almost certainly have changed by the time you read this. Have a browse of the CentOS mirror site to find the current versions:

32 bit systems:
64 bit systems:

Replace the ‘x’ values below with the current version numbers

CentOS 6.5 / 32-bit packages required


CentOS 6.5 / 64-bit packages required


Initial Conversion

Clean up yum’s cache

# yum clean all

Import the GPG key for the appropriate version of CentOS

# rpm --import RPM-GPG-KEY-CentOS-6

Remove Core RHEL packages

# yum remove rhnlib abrt-plugin-bugzilla redhat-release-notes*
# rpm -e --nodeps redhat-release-server-6Server redhat-indexhtml

The ‘rpm -e’ command might fail saying one of the packages is not installed. If so, just remove that package from the command and run it again.

Remove RHEL subscription-manager

# subscription-manager clean
# yum remove subscription-manager

This stops yum from throwing up an error message every time you run it, something like “This system is not registered to Red Hat Subscription Management.”

Force install the core CentOS RPMs you downloaded

# rpm -Uvh --force *.rpm


Clean up yum and then upgrade

# yum clean all
# yum upgrade

I rebooted the machine at this point, just to assure myself that it would come back up properly. At the same time, I noticed that the descriptions in /boot/grub/grub.conf still mentioned RedHat – a quick edit soon sorted that out, replacing all instances of RedHat with CentOS.

Purify Remaining Packages

Once the server is back up and running, a first pass at removing the remaining RHEL packages can be undertaken:

# yum clean all
# yum reinstall $(rpm -qa --qf "%{NAME} %{VENDOR} \n" | grep "Red Hat" | cut –d" " -f1)
# yum remove Red_Hat_Enterprise_Linux-Release_Notes-6-en-US

The reinstall command above will cleanly replace a large portion of the installed RedHat packages. It will, however, almost certainly leave some packages behind. My approach was to run that command multiple times until it was no longer able to replace any of the remaining packages due to various dependency problems. I then carried out another reboot to satisfy myself that nothing was broken.
At this point you can get a full list of what’s left by running this command:

rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE} %{VENDOR} \n" | grep "Red Hat"

It’s pretty much up to you how much work you want to put into replacing any remaining RedHat packages. The notes below highlight a handful of extra items that I decided to tackle:

Replace ntp/ntpdate packages

# cp /etc/ntp/step-tickers /etc/ntp/step-tickers.keep
# cp /etc/ntp.conf /etc/ntp.conf.keep
# yum remove ntp ntpdate
# yum clean all
# yum install ntp ntpdate
# mv /etc/ntp/step-tickers.keep /etc/ntp/step-tickers
# mv /etc/ntp.conf.keep /etc/ntp.conf

Replace plymouth boot scripts

# rpm -e --nodeps plymouth plymouth-scripts plymouth-core-libs
# yum clean all
# yum install plymouth plymouth-scripts plymouth-core-libs

Replace dbus-glib package

# rpm -e --nodeps dbus-glib
# yum clean all
# yum install dbus-glib

Replace initscripts package

# rpm -e --nodeps initscripts
# yum clean all
# yum install initscripts

At this point in the process, you should see that just about the only RedHat packages left are for the kernel. The recommendation is to just ignore them, on the grounds that trying to safely remove/replace a running kernel is just too risky. The test server where this process was developed/tested installed an updated CentOS kernel without incident the next time an updated package was released. The default /etc/yum.conf setting is to retain a maximum of 5 installed kernels, so over time, the RedHat kernels will gradually be aged out.