Convert a CentOS 6 install to a Scientific Linux 6 install


CentOS, Scientific Linux ("SL"), and Oracle Linux are all based on the Red Hat Enterprise Linux ("RHEL") code base. Though there are differences between them, the similarities are more than not. For whatever the reason, there are documented processes that permit the conversion from one of the aforementioned Linux distros to another. This conversion will document another approach based on those documented processes.

Reasons for conversions will vary and some will suggest against converting distros. My reasons for converting CentOS to SL is two-fold. One, to see if I could do it, the short answer, yes. The second, while studying for the RHCA exam, a book titled, Red Hat Linux Certification Practice Exams with Virtual Machines: (exams EX200 & EX300) contains a DVD with three virtual machines. From reading online reviews and a few chapters into the book, there is no indication what the virtual machine distros are other than compressed KVMs. These virtual machines are all SL distros. Well, having created a CentOS host machine, I wanted the host machine to match that of the KVMs for a more consistent environment. The reason for that, if in the event I wanted to test Kickstart installations or use the host as a repository to the virtual machines. Again, this was more of a test to see if I can perform this conversion, though I haven't performed it on my host machine as of this writing.

Anyway, here is the process, in the form of a script.

# Description: Convert a CentOS 6.x install into a Scientific Linux ("SL") 6.5 install

# Install SL repos and GPG keys
if [ $(arch) = "i686" ]; then
      # 32-bit
      rpm -ivh
      rpm -ivh --force
      # 64-bit
      rpm -ivh
      rpm -ivh --force

# Remove CentOS repos and more
yum erase centos-release -y

if test -n "$(find /etc/yum.repos.d -maxdepth 1 -name 'CentOS*' -print -quit)"; then
     mv /etc/yum.repos.d/CentOS* /tmp

sed-i's/distroverpkg=centos-release/distroverpkg=sl-release/g' /etc/yum.conf

# Add SL packages
yum distro-sync -y
# Reinstall any component that was CentOS
yum reinstall `rpm -q -a --qf "%{Name} %{Vendor}\n" | grep CentOS | awk '{print $1}'` -y
# Since not everything existed as a reinstall, remove any remaining packages, excluding the kernel
yum remove `rpm -q -a --qf "%{Name} %{Vendor}\n" | grep CentOS | awk '{print $1}' | grep -v 'kernel*'` -y
yum upgrade --releasever=6.5 -y

Though this process does convert over the distribution, applications will need to be tested and verified to work. While more testing is needed, the original goal to convert CentOS to Scientific Linux was met.

Jang, Michael H. RHCSA/RHCE Red Hat Linux Certification Practice Exams with Virtual Machines: (exams EX200 & EX300). New York: McGraw Hill, 2013. Print.