Inplace migration from Oracle Linux 7 to CentOS 7

Author: | Posted in distro, howto 1 Comment

This is my 2nd attempt to migrate from Oracle Linux to CentOS; a while ago I tested it with success on OL6.4. This time I’m using an OL7 VM instance with a default desktop installation. Having 3rd party repositories installed on OL7 should not cause any issues when switching to CentOS as the RPMs from the EL7 repos are usually compatible with most EL7 clones, except for maybe drivers compiled against specific kernel versions such as Nvidia. I only had the EPEL repo configured with 1 or 2 packages installed, so I didn’t have any problems.

 

1. Make kernel-uek default and update the OS

 

Changing the default kernel (from kernel to kernel-uek) in /etc/sysconfig/kernel is not mandatory, as one can choose to boot a specific kernel while in the Grub2 menu. However, changing the file will automatically configure any new kernel-uek as default, which is what we need.

sed -i 's/DEFAULTKERNEL=kernel/DEFAULTKERNEL=kernel-uek/' /etc/sysconfig/kernel
yum update

 

2. Confirm kernel-uek is the default or otherwise select it manually

 

If the above yum command didn’t find any updates to the kernel RPMs, the Grub2 configuration hasn’t changed. In this case we can change the default kernel manually. The following tool returns the current default kernel:

grub2-editenv list

My OL 7 installation was using the Red Hat Compatible Kernel as default, so I changed it:

awk -F "'" '$1=="menuentry " {print $2}' /boot/grub2/grub.cfg
Oracle Linux Server, with Linux 3.10.0-123.el7.x86_64
Oracle Linux Server, with Linux 3.10.0-123.20.1.el7.x86_64
Oracle Linux Server, with Unbreakable Enterprise Kernel 3.8.13-55.1.5.el7uek.x86_64
Oracle Linux Server, with Unbreakable Enterprise Kernel 3.8.13-35.3.1.el7uek.x86_64
Oracle Linux Server, with Linux 0-rescue-f4f6b4c2976d454eade4da24993a1308
grub2-set-default 'Oracle Linux Server, with Unbreakable Enterprise Kernel 3.8.13-55.1.5.el7uek.x86_64'

 

3. Change the default target (runlevel) and restart

 

systemctl set-default multi-user.target
reboot

 

4. Install the CentOS repos

 

After rebooting into Oracle’s kernel UEK3 we are ready to proceed. First, remove Oracle-specific RPMs and install the CentOS repository files.

rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
rpm -e --nodeps `rpm -qa | egrep 'redhat|oracle|rhn|uname26|libdtrace-ctf'`
yum install http://mirror.centos.org/centos/7/updates/x86_64/Packages/centos-release-7-0.1406.el7.centos.2.6.x86_64.rpm

5. Downgrade yum

 

Same as with OL6, Oracle added additional suffixes to some of its packages. Example for yum:

OL7: yum-3.4.3-118.0.2.el7.noarch
CentoS7: yum-3.4.3-118.el7.centos.noarch

As we now have the CentOS repos installed, downgrading yum will remove the OL7 package and install the CentOS RPM which is lower in version.

yum downgrade yum
yum clean all
yum repolist

 

6. Downgrade all other packages that have the additional suffixes

 

As opposed to OL6 where I only noticed either 0.1 or 0.2 added to the %{RELEASE} RPM tag, I found there are more suffixes on OL7.

cd /root
rpm -qa | egrep "\.0\.[1-9]\.el7" >> to_downgrade
cat to_downgrade | while read package; do rpm -q $package --qf '%{NAME}\n' >> dgrlist; done
yum downgrade `cat dgrlist`

The last command performed a downgrade on 135 packages on my system.

 

7. Reinstall existing packages

 

After downgrading the RPMs with additional suffixes, the remaining ones should be of the same version as with CentOS, so we will attempt to reinstall all of them.

rpm -qa --qf '%{NAME}:%{VENDOR}\n' |  grep  Oracle >> oraclepacks
cat oraclepacks | awk -F":" '{print $1}' >> oraclepacks2
yum reinstall `cat oraclepacks2`

The last yum command reinstalled 1043 packages on my machine, so it takes some time. There were some RPMs that were not successfully reinstalled for whatever reasons and one of them was a Red Hat kernel. My OL7 installation had 2 different Red Hat kernels installed: 3.10.0-123 and 3.10.0-123.20.1, but only the 1st one was reinstalled from the CentOS repositories, so I decided to remove the second kernel, make the first one the new default and reboot.

rpm -e --nodeps `rpm -qa | grep 3.10.0-123.20.1`
sed -i 's/DEFAULTKERNEL=kernel-uek/DEFAULTKERNEL=kernel/' /etc/sysconfig/kernel
sed -i 's/Oracle\ Linux\ Server/CentOS\ Linux/g;s/oracle/centos/g' /boot/grub2/grub.cfg
grub2-set-default 'CentOS Linux, with Linux 3.10.0-123.el7.x86_64'
reboot

 

8. Deal with leftovers

 

At this point we are almost done. The OS is running the Red Hat kernel, so we can get rid of kernel-uek. We’ll also take care of the remaining RPMs that were not reinstalled during step #7. An easy method is to perform a downgrade followed by an update.

rpm -e --nodeps `rpm -qa | grep kernel-uek`
rpm -qa --qf '%{NAME}:%{VENDOR}\n' |  grep  Oracle >> oraclepacks3
cat oraclepacks3 | awk -F":" '{print $1}' >> oraclepacks4
yum downgrade `cat oraclepacks4`
yum update

 

9. Final check

 

Removing packages with the “–nodeps” argument could cause issues on a machine and it is generally not recommended. During the migration process we removed the kernel headers RPM which may be required for other packages. After installing it again and doing a final check, there should be no problems reported by yum.

yum install kernel-headers
yum check

All Oracle Linux RPMs are now replaced with CentOS packages. A last sanity check is recommended to identify any potential configuration changes and investigate further, if needed.

updatedb
locate *.rpm{save,orig,new}

Comments
  1. Posted by Robert Litman

Add Your Comment