IMPORTANT NOTE: Before doing the upgrade make sure the following done.
- Disable SElinux
- Remove unnecessary repositories
- mkdir /etc/yum.repos.d/backups
- mv /etc/yum.repos.d/Centos* /etc/yum.repos.d/backups
- Take a recent backup if required
1. Update your system to latest Centos 6 version – yum upgrade -y
2. Reboot your system – reboot
cat /etc/redhat-release
CentOS release 6.10 (Final)
uname -r
2.6.32-754.23.1.el6.x86_64
3. Update the Centos Upgrade repo
vi /etc/yum.repos.d/upgrade.repo
[upgrade]
name=upgrade
baseurl=https://buildlogs.centos.org/centos/6/upg/x86_64/
enabled=1
gpgcheck=0
4. Clean and check the repo
yum clean all ; yum repolist
5. Install the Upgrade packages
yum -y install preupgrade-assistant-contents redhat-upgrade-tool preupgrade-assistant
6. Run the Preupgrade Assistant to check anything that might adversely affect the success of your upgrade.
preupg
NOTE: If you get an error preupg: error: [Errno 2] No such file or directory: ‘/root/preupgrade/result.html’
Do the following
- yum erase openscap
- yum install https://buildlogs.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm
- yum install redhat-upgrade-tool preupgrade-assistant-contents
After success run, the report file will be available /root/preupgrade/result.html . You can move the file to any web server and check.
7. Append CentOS Vault under mirrorlist:
mkdir -pv /var/tmp/system-upgrade/base/ /var/tmp/system-upgrade/extras/ /var/tmp/system-upgrade/updates/
echo http://vault.centos.org/7.0.1406/os/x86_64/ > /var/tmp/system-upgrade/base/mirrorlist.txt
echo http://vault.centos.org/7.0.1406/extras/x86_64/ > /var/tmp/system-upgrade/extras/mirrorlist.txt
echo http://vault.centos.org/7.0.1406/updates/x86_64/ > /var/tmp/system-upgrade/updates/mirrorlist.txt
8. Import Centos 7 key
rpm –import http://vault.centos.org/7.0.1406/os/x86_64/RPM-GPG-KEY-CentOS-7
9. Add Centos 7 repo
vi /etc/yum.repos.d/centos7.repo
[centos7]
name=centos7
baseurl=http://mirror.centos.org/centos/7/os/x86_64/
enabled=1
gpgcheck=0
10. Clean and check the repo
yum clean all ; yum repolist
11. Run the Upgrade
centos-upgrade-tool-cli –force –network=7 –instrepo=http://vault.centos.org/7.0.1406/os/x86_64/ –cleanup-post
12. Reboot when it prompts to start the upgrade – reboot
13. The system starts the upgrade and this takes some time, the ssh service may be stopped after the system boot up, start the ssh service from the console. – systemctl enable –now sshd
14. Start any other services if any
systemctl enable –now httpd
Note : if you have mysql, then 7 upgrade to mariadb. Mariadb may fail to start, you need to fix this.
15. Check the versions
cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
uname -r
3.10.0-1062.el7.x86_64
16. Remove the repos
mv /etc/yum.repos.d/upgrade.repo /etc/yum.repos.d/backups mv /etc/yum.repos.d/centos7.repo /etc/yum.repos.d/backups
17. Clean and check the repo
yum clean all ; yum repolist
18. Again update the system
yum update
19. Reboot the system. Centos 7 upgrade is now completed successfully