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.
#!/bin/bash # 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 http://ftp.scientificlinux.org/linux/scientific/6x/i386/os/Packages/yum-conf-sl6x-1-2.noarch.rpm rpm -ivh --force http://ftp.scientificlinux.org/linux/scientific/6x/i386/os/Packages/sl-release-6.4-1.i686.rpm else # 64-bit rpm -ivh http://ftp.scientificlinux.org/linux/scientific/6x/x86_64/os/Packages/yum-conf-sl6x-1-2.noarch.rpm rpm -ivh --force http://ftp.scientificlinux.org/linux/scientific/6x/x86_64/os/Packages/sl-release-6.4-1.x86_64.rpm fi # 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 fi 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.
Source(s)
http://blog.bradiceanu.net/2011/09/02/how-to-convert-centos-6-0-to-scientific-linux-6-x/
http://nixgeek.com/convert-centos-6-server-to-scientific-linux-6.html
http://unix.stackexchange.com/questions/22560/list-all-rpm-packages-installed-from-repo-x
http://askubuntu.com/questions/41332/how-do-i-check-if-i-have-a-32-bit-or-a-64-bit-os
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-6.html
http://stackoverflow.com/questions/6363441/check-if-a-file-exists-with-wildcard-in-shell-script
Jang, Michael H. RHCSA/RHCE Red Hat Linux Certification Practice Exams with Virtual Machines: (exams EX200 & EX300). New York: McGraw Hill, 2013. Print.