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: http://mirror.centos.org/centos/6/os/i386/Packages/
64 bit systems: http://mirror.centos.org/centos/6/os/x86_64/Packages/

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

CentOS 6.5 / 32-bit packages required

RPM-GPG-KEY-CentOS-6
centos-release-6-x.el6.centos.x.x.i686.rpm
centos-indexhtml-6-x.el6.centos.noarch.rpm
yum-x.x.x-x.el6.centos.noarch.rpm
yum-plugin-fastestmirror-x.x.x-x.el6.noarch.rpm

CentOS 6.5 / 64-bit packages required

RPM-GPG-KEY-CentOS-6
centos-release-6-x.el6.centos.xx.x.x86_64.rpm
centos-indexhtml-6-x.el6.centos.noarch.rpm
yum-x.x.xx-xx.el6.centos.noarch.rpm
yum-plugin-fastestmirror-x.x.xx-xx.el6.noarch.rpm

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.

RPM Packages for CentOS Linux

I have a bunch of RPM packages that I’ve made for CentOS over the last couple of years – nothing hugely earth-shattering, but just some stuff that I like to install by default whenever I have to build a new machine. I’ve created a yum repository on the same server that hosts this web site, so feel free to go ahead and make use of it!

To use this repository with (for example) the yum package manager, download and install linux2000-repo-1.0-1pke.noarch.rpm. This will also install the GPG public key that I use to sign my packages, allowing you to verify that downloaded RPMS have not been tampered with in transit to you.

If you would like to browse the contents of my repo to see what packages are contained therein, the URLs are:

Binary packages: http://packages.linux2000.com/l2k6server-x86_64/rpm

Source packages: http://packages.linux2000.com/l2k6server-x86_64/sources

Please note that my packages are intended to be used on a 64-bit install of CentOS v6.x. They *may* be compatible with a 64-bit install of RedHat Enterprise Linux v6.x, but I have not tested this. I have no plans to port these packages to other versions of CentOS or to other Linux distributions. Source RPMs are available for those who want to try.

These packages are offered as a public service in the hope that they will be considered useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Any use you may make of the contents of this repository is understood by you to be entirely at your own risk.

Feedback, comments or suggestions for improvements can be made to the e-mail address for me which is embedded in most of these packages.