Posted By: Tony Baird
Last Updated: Thursday April 25, 2024
AlmaLinux recently released tools and a guide for migrating from CentOS 6 to CentOS 7. We haven’t offered CentOS 6.9 in some time, but there was a time when we did offer CentOS 6 as an operating system option. We decided to take our last known CentOS 6 image and use the redhat-upgrade-tool to move to CentOS 7.
The first step is going to switch to a CentOS 6 vault repo:
curl https://repo.almalinux.org/elevate/el6/centos6-vault.repo -o /etc/yum.repos.d/CentOS-Base.repo
Once you’ve done this, update to the latest version of all packages using the following:
yum update
At this point, it’s best to reboot your server if there are any updates. Once the server has been rebooted, confirm you’re running CentOS 6.10:
cat /etc/centos-release
CentOS release 6.10 (Final)
You’re now ready to start the Elevate process
yum install https://repo.almalinux.org/elevate/elevate-release-latest-el6.noarch.rpm
Install the upgrade tools:
yum install redhat-upgrade-tool preupgrade-assistant-contents
You’re now ready to check for potential issues:
preupg
You can view the output of that by running:
preupg --riskcheck --verbose
Once you’ve resolved any issues, you can run the following:
rpm --import https://vault.centos.org/7.2.1511/os/x86_64/RPM-GPG-KEY-CentOS-7
To start the upgrade
redhat-upgrade-tool --network=7 --cleanup-post --instrepo=http://vault.centos.org/7.2.1511/os/x86_64/
Upon completion, you will need to reboot your system:
reboot
Upon reboot, you can watch your server from the console while it performs the necessary upgrade steps.
After the process has been completed you should be back at a login screen, and if you login to your system, you should have an output of:
cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)
After this, you can remove any el6 packages. In my case, the only remaining were:
Which I removed with the following:
yum remove redhat-upgrade-tool-0.8.0-10.el6.noarch elevate-release-1.0-2.el6.noarch
Now we need to move from CentOS 7.2.1511 to CentOS 7.9.2009. You’ll need to confirm you’re seeing the following:
ls -la /etc/yum.repos.d/CentOS-Base.repo.rpmnew
-rw-r--r-- 1 root root 1664 Dec 9 2015 /etc/yum.repos.d/CentOS-Base.repo.rpmnew
rpm -qV centos-release
S.5....T. c /etc/yum.repos.d/CentOS-Base.repo
Assuming this matches for you then you can move the repo file:
mv /etc/yum.repos.d/CentOS-Base.repo.rpmnew /etc/yum.repos.d/CentOS-Base.repo
Then we need to yum update:
yum update
After rebooting, you should be on CentOS 7.9.2009:
cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
Of course, with CentOS 7 soon becoming end of life, the work isn’t done. You could elevate from CentOS 7 to AlmaLinux 8 with a bit of work.