CentOS 7 Supports In-Place Upgrading from CentOS 6.x for 64-bit Versions
This article covers upgrading a minimal CentOS 6.x system to CentOS 7. CentOS is a popular GNU/Linux OS for servers (including web servers) and workstations. Popular because it is a community based version of RHEL. CentOS is often an OS option when purchasing and setting up a VPS. The current major version of CentOS is version 7. CentOS 7 can be installed via an in-place upgrade over CentOS 6. However, CentOS 7 is only a 64-bit OS and therefore the system being upgraded has to be running 64-bit CentOS 6.
NOTE: This article is for archived information purposes only. According to the CentOS Upgrade Tool web page, the tool is currently broken.
To check if CentOS is 64-bit or 32-bit use the uname command with the -p option (p for processor):
[root@servername ~]# uname -p
The 64-bit CentOS will display x86_64 and 32-bit will display i686.
Words of caution. If your system has been highly customised then performing an in-place upgrade from CentOS 6 to 7 may not be successful. In this case, as for upgrading a 32-bit system, a data backup, new CentOS 7 installation and data restore will be required. Do you need CentOS 7 now? There is also no need to rush to upgrade to CentOS 7. CentOS 6 will be receiving updates until the end of 2020. This article is for informational and test purposes only. You are responsible for you own actions and an in-place upgrade from CentOS 6 to CentOS 7 is probably more trouble than doing a fresh CentOS 7 install and data restore. For example upgrading a minimal CentOS 6.6. to CentOS 7 may not work according to this bug report.
The other consideration is whether the new CentOS 7 features will hinder operation of your system. The new features may require changes to the normal workflow or they may be incompatible with software that is being used on the system. Whilst the CentOS 7 Release Notes list some major changes the RHEL 7 Release Notes has a detailed discussion.
Backup Your Data
The most important step before performing any update or upgrade is to take a backup of all data. Performing a regular backup means that more than one copy of the data required is available to restore should anything go wrong. A copy of the last two or three backups should be available. Ideally stored on separate media in a safe place.
Practice Makes Perfect
Get familiar with the update and upgrade process. A good way to do this is to try it on a VM on your local system. Ideally the VM will mimic the live system set-up. This article is based upon an upgrade from a minimal CentOS 6 system running on a VirtualBox VM on a Windows 8.1 system. CentOS running in a VM is similar to CentOS running as a VPS.
Update CentOS 6 to the Latest Point Release
Before upgrading a system from CentOS 6 to CentOS 7 the CentOS 6 system needs to be updated to the latest 6.x version and rebooted. The update is performed with the yum command:
[root@servername ~]# yum update
Full details of updating CentOS to the latest point release and rebooting can be found in the article CentOS Version Command and Update CentOS to New Version.
Install Upgrade Assistant
Create a repo file for the upgrade assistant. On the minimal installation of CentOS this can be done with the vi editor. The repo file will sit in /etc/yum.repos.d and named upgradetool.repo:
[root@servername ~]# vi /etc/yum.repos.d/upgradetool.repo
In vi type i to enter insert mode and add these lines to the new repo file:
name=CentOS-$releasever – Upgrade Tool
Save the file by hitting the escape key (Esc) and type the write and quit command using :wq (colon and w and q keys).
Use yum to install the upgrade assistant:
[root@servername ~]# yum install redhat-upgrade-tool preupgrade-assistant-contents
If you get an error similar to the following it is likely you are trying to install the upgrade assistant on 32-bit CentOS. Only 64-bit CentOS 6 to CentOS 7 in-place upgrade is possible:
Error: Package: 1:redhat-upgrade-tool-0.7.22-3.el6.centos.noarch (upg)
Requires: preupgrade-assistant >= 1.0.2-4
Error: Package: preupgrade-assistant-contents-0.5.14-1.el6.centos.noarch (upg)
Requires: preupgrade-assistant (x86-64) >= 1.0.2-4
(Above error is seen if trying to install Red Hat Upgrade Tool on 32-bit CentOS 6.x)
Run the Pre-upgrade Assistant
The pre-upgrade utility, preupg, performs an upgrade analysis for the system.
View the pre-upgrade utility options using –help or -h:
[root@servername ~]# preupg -h
The list command should show CentOS6_7:
[root@servername ~]# preupg -l
Run the command to perform the analysis (it does not do the upgrade, it will display a reminder about having backups available in case the upgrade fails):
[root@servername ~]# preupg -s CentOS6_7
Enter y to proceed. After the analysis the results are stored in the /root/preupgrade directory, in result.html and result.xml files and various subdirectories. All the contents of the preupgrade directory are also copied to an archive file.
Review the Pre-upgrade Results
If not moving the result files to a different system for review, then on a minimal system viewing the files in the command shell is difficult. The best approach is to install a text based web page viewer. The utility w3m is ideal.
[root@servername ~]# yum install w3m w3m-img w3m-el
(It is a good idea to install w3m before running the pre-update utility so that it can also be analysed.)
Pass w3m the result.html file and it is easier to view the pre-upgrade report.
[root@servername ~]# w3m preupgrade/result.html
Use the report to determine any required action to deal with potential upgrade issues. The greater the amount of customisation to a system the larger the potential task of the post upgrade work. For additional information see the CentOS Upgrade Tool web page, in particular what the contents of the various directories are for, the meaning of the various results and the risk levels explanation.
Run the Red Hat Upgrade Tool
First import the CentOS 7 RPM key:
[root@servername ~]# rpm –import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
Run the upgrade:
[root@servername ~]# centos-upgrade-tool-cli –network 7 –instrepo=http://mirror.centos.org/centos/7/os/x86_64
Answer y after the informational messages to continue (this is your chance to cancel the upgrade). Restart the system:
[root@servername ~]# reboot
The installation will complete, and, fingers-crossed, work.
Complete Any Further Steps Required
Any steps identified by the upgrade report will need completing and a full operational shakedown. If you decided not to do an in-place upgrade remember CentOS 6 will be supported until 2020, also consider a fresh install of CentOS 7 as an alternative to an in-place upgrade.