Upgrade CentOS6 to CentOS7

In this article, you will learn about how to upgrade CentOS6 to CentOS7.

In earlier days, it was not possible to upgrade from one major version to another major version without the complete formatting of the Linux. But, now there are many options available to upgrade to the Linux version. So in this tutorial, you are going to look for an upgrade from CentOS 6 to CentOS 7.

I always recommend taking the backup of existing data before starting any upgrade. So, If you get any problems during the upgrade then, it will be easy for you to do a fresh installation of CentOS 7 and, you can migrate the data to the newly installed operating system.

Preconditions

  • A VPS or a local server on which CentOS 6 latest version is running. (CentOS 6.5 or later)
  • You must log in with a root user or a user with sudo privilege to make the changes.
  • Disable selinux
  • Remove unnecessary repositories
  • Internet connection

Step 1: Checking for the latest update available for CentOS 6

Before, starting the upgrade we have to follow a few steps.

Firstly, we are going to check if any update is available for CentOS 6. So, use the below command to check the update.

yum update

The above command will update your system software packages with the latest version. If it is asking for your confirmation then press y to accept the confirmation and hit the enter key.

Step 2: Creating a new CentOS repository 

As for testing purposes, we have to install the pre-upgrade assistant tool and this tool is not available in the default repository. So, again we have to install it from the developer repository. For this reason, now we are going to create a repository file with the name upgrade.repo in /etc/yum.repos.d. I’m using vim editor but you can use any other editor as per your choice like vi, pico, nano, etc.

vim /etc/yum.repos.d/upgrade.repo

And, add the below lines,

[centos-upgrade]
name=centos-upgrade
baseurl=https://buildlogs.centos.org/centos/6/upg/x86_64/
enabled=1
gpgcheck=0

As we have created the repository file.

Step 3: Installing the pre-upgrade assistant tool

Firstly, we are going to install the openscap version from dev.centos.org. So, use the below command to complete this installation.

yum install -y https://buildlogs.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm

Secondly, install the Redhat pre-upgrade assistant tool

yum install -y redhat-upgrade-tool preupgrade-assistant-*

Step 4: Running the pre-upgrade assistant tool

So, this is the time to run the pre-upgrade assistant tool to check it. Use the below command to test it.

preupg

And, you will get the below output but there may be some differences for you. This output will give you the packages and applications that will be affected by this upgrade. If everything is ok for you then you can proceed to the next step.

Preupg tool doesn't do the actual upgrade.
Please ensure you have backed up your system and/or data in the event of a failed upgrade
that would require a full re-install of the system from installation media.
Do you want to continue? y/n
y
Gathering logs used by preupgrade assistant:
All installed packages : 01/11 ...finished (time 00:00s)
All changed files : 02/11 ...finished (time 00:10s)
Changed config files : 03/11 ...finished (time 00:00s)
All users : 04/11 ...finished (time 00:00s)
All groups : 05/11 ...finished (time 00:00s)
Service statuses : 06/11 ...finished (time 00:00s)
All installed files : 07/11 ...finished (time 00:00s)
All local files : 08/11 ...finished (time 00:00s)
All executable files : 09/11 ...finished (time 00:00s)
RedHat signed packages : 10/11 ...finished (time 00:00s)
CentOS signed packages : 11/11 ...finished (time 00:00s)
Assessment of the system, running checks / SCE scripts:
001/096 ...done (Configuration Files to Review)
002/096 ...done (File Lists for Manual Migration)
003/096 ...done (Bacula Backup Software)
004/096 ...done (MySQL configuration)
005/096 ...done (Migration of the MySQL data stack)
006/096 ...done (Changes related to moving from MySQL to MariaDB)
007/096 ...done (PostgreSQL upgrade content)
008/096 ...running (GNOME Desktop Environment underwent several design modifications in CentOS 7done (GNOME Desktop Environment underwent several design modifications in CentOS 7 release)
009/096 ...running (KDE Desktop Environment underwent several design modifications in CentOS 7 rdone (KDE Desktop Environment underwent several design modifications in CentOS 7 release)
010/096 ...done (several graphic drivers not supported in CentOS 7)
011/096 ...done (several input drivers not supported in CentOS 7)
012/096 ...done (several kernel networking drivers not available in CentOS 7)
013/096 ...done (several kernel storage drivers not available in CentOS 7)
014/096 ...done (Names, Options and Output Format Changes in arptables)
015/096 ...done (BIND9 running in a chroot environment check.)
016/096 ...done (BIND9 configuration compatibility check)
017/096 ...done (Move dhcpd/dhcprelay arguments from /etc/sysconfig/* to *.service files)
018/096 ...done (DNSMASQ configuration compatibility check)
019/096 ...done (Dovecot configuration compatibility check)
020/096 ...done (Compatibility Between iptables and ip6tables)
021/096 ...done (Net-SNMP check)
022/096 ...done (Squid configuration compatibility check)
023/096 ...done (Reusable Configuration Files)
024/096 ...done (VCS repositories)
025/096 ...done (Added and extended options for BIND9 configuration)
026/096 ...done (Added options in DNSMASQ configuration)
027/096 ...done (Packages not signed by CentOS)
028/096 ...done (Obsoleted rpms)
029/096 ...done (w3m not available in CentOS 7)
030/096 ..done (report incompatibilities between CentOS 6 and 7 in qemu-guest-agent package))031/096 ...done (Removed options in coreutils binaries)
032/096 ...done (Removed options in gawk binaries)
033/096 ...done (Removed options in netstat binary)
034/096 ...done (Removed options in quota tools)
035/096 ...done (Removed rpms)
036/096 ...done (Replaced rpms)
037/096 ...done (GMP library incompatibilities)
038/096 ...done (package downgrades)
039/096 ...done (restore custom selinux configuration)
040/096 ...done (General)
041/096 ...done (samba shared directories selinux)
042/096 ...done (CUPS Browsing/BrowsePoll configuration)
043/096 ...done (CVS Package Split)
044/096 ...done (FreeRADIUS Upgrade Verification)
045/096 ...done (httpd configuration compatibility check)
046/096 ...done (bind-dyndb-ldap)
047/096 ...done (Identity Management Server compatibility check)
048/096 ...done (IPA Server CA Verification)
049/096 ...done (NTP configuration)
050/096 ...done (Information on time-sync.target)
051/096 ...done (OpenLDAP /etc/sysconfig and data compatibility)
052/096 ...done (OpenSSH sshd_config migration content)
053/096 ...done (OpenSSH sysconfig migration content)
054/096 ...done (Configuration for quota_nld service)
055/096 ...done (Disk quota netlink message daemon moved into quota-nld package)
056/096 ...done (SSSD compatibility check)
057/096 ...done (Luks encrypted partition)
058/096 ...done (Clvmd and cmirrord daemon management.)
059/096 ...done (State of LVM2 services.)
060/096 ...done (device-mapper-multipath configuration compatibility check)
061/096 ...done (Removal of scsi-target-utils)
062/096 ...done (Configuration for warnquota tool)
063/096 ...done (Disk quota tool warnquota moved into quota-warnquota package)
064/096 ...done (Architecture Support)
065/096 ...done (Binary rebuilds)
066/096 ...done (Debuginfo packages)
067/096 ...done (Cluster and High Availability)
068/096 ...done (Quorum implementation)
069/096 ...done (fix krb5kdc config file)
070/096 ...done (File Systems, Partitions and Mounts Configuration Review)
071/096 ...done (Read Only FHS directories)
072/096 ...done (Sonamebumped libs)
073/096 ...done (SonameKept Reusable Dynamic Libraries)
074/096 ...done (Removed .so libs)
075/096 ...done (In-place Upgrade Requirements for the /usr/ Directory)
076/096 ...done (CA certificate bundles modified)
077/096 ...done (Developer Tool Set packages)
078/096 ...done (Hyper-V)
079/096 ...done (Content for enabling and disabling services based on CentOS 6 system)
080/096 ...done (Check for ethernet interface naming)
081/096 ...done (User modification in /etc/rc.local and /etc/rc.d/rc.local)
082/096 ...done (cgroups configuration compatibility check)
083/096 ...done (Plugable authentication modules (PAM))
084/096 ...done (Foreign Perl modules)
085/096 ...done (Python 2.7.5)
086/096 ...done (Ruby 2.0.0)
087/096 ...done (SCL collections)
088/096 ...done (System kickstart)
089/096 ...done (YUM)
090/096 ...done (Check for usage of dangerous range of UID/GIDs)
091/096 ...done (Incorrect usage of reserved UID/GIDs)
092/096 ...done (NIS ypbind config files back-up)
093/096 ...done (NIS Makefile back-up)
094/096 ...done (NIS server maps check)
095/096 ...done (NIS server MAXUID and MAXGID limits check)
096/096 ...done (NIS server config file back-up)
Assessment finished (time 01:02s)
Result table with checks and their results for main contents:
---------------------------------------------------------------------------------------------------------------
|Bacula Backup Software |notapplicable |
|MySQL configuration |notapplicable |
|Migration of the MySQL data stack |notapplicable |
|Changes related to moving from MySQL to MariaDB |notapplicable |
|PostgreSQL upgrade content |notapplicable |
|GNOME Desktop Environment underwent several design modifications in CentOS 7 release |notapplicable |
|KDE Desktop Environment underwent several design modifications in CentOS 7 release |notapplicable |
|several graphic drivers not supported in CentOS 7 |notapplicable |
|several input drivers not supported in CentOS 7 |notapplicable |
|Names, Options and Output Format Changes in arptables |notapplicable |
|BIND9 running in a chroot environment check. |notapplicable |
|BIND9 configuration compatibility check |notapplicable |
|Move dhcpd/dhcprelay arguments from /etc/sysconfig/* to *.service files |notapplicable |
|DNSMASQ configuration compatibility check |notapplicable |
|Dovecot configuration compatibility check |notapplicable |
|Net-SNMP check |notapplicable |
|Squid configuration compatibility check |notapplicable |
|Added and extended options for BIND9 configuration |notapplicable |
|Added options in DNSMASQ configuration |notapplicable |
|w3m not available in CentOS 7 |notapplicable |
|report incompatibilities between CentOS 6 and 7 in qemu-guest-agent package |notapplicable |
|Removed options in quota tools |notapplicable |
|restore custom selinux configuration |notapplicable |
|samba shared directories selinux |notapplicable |
|CUPS Browsing/BrowsePoll configuration |notapplicable |
|CVS Package Split |notapplicable |
|FreeRADIUS Upgrade Verification |notapplicable |
|bind-dyndb-ldap |notapplicable |
|Identity Management Server compatibility check |notapplicable |
|IPA Server CA Verification |notapplicable |
|NTP configuration |notapplicable |
|Information on time-sync.target |notapplicable |
|OpenLDAP /etc/sysconfig and data compatibility |notapplicable |
|Configuration for quota_nld service |notapplicable |
|Disk quota netlink message daemon moved into quota-nld package |notapplicable |
|SSSD compatibility check |notapplicable |
|Luks encrypted partition |notapplicable |
|Clvmd and cmirrord daemon management. |notapplicable |
|device-mapper-multipath configuration compatibility check |notapplicable |
|Removal of scsi-target-utils |notapplicable |
|Configuration for warnquota tool |notapplicable |
|Disk quota tool warnquota moved into quota-warnquota package |notapplicable |
|Quorum implementation |notapplicable |
|fix krb5kdc config file |notapplicable |
|cgroups configuration compatibility check |notapplicable |
|Ruby 2.0.0 |notapplicable |
|SCL collections |notapplicable |
|NIS ypbind config files back-up |notapplicable |
|NIS Makefile back-up |notapplicable |
|NIS server maps check |notapplicable |
|NIS server MAXUID and MAXGID limits check |notapplicable |
|NIS server config file back-up |notapplicable |
|several kernel networking drivers not available in CentOS 7 |pass |
|several kernel storage drivers not available in CentOS 7 |pass |
|Reusable Configuration Files |pass |
|OpenSSH sshd_config migration content |pass |
|Architecture Support |pass |
|Binary rebuilds |pass |
|Debuginfo packages |pass |
|Cluster and High Availability |pass |
|Read Only FHS directories |pass |
|In-place Upgrade Requirements for the /usr/ Directory |pass |
|CA certificate bundles modified |pass |
|Developer Tool Set packages |pass |
|Hyper-V |pass |
|Check for ethernet interface naming |pass |
|User modification in /etc/rc.local and /etc/rc.d/rc.local |pass |
|Plugable authentication modules (PAM) |pass |
|Python 2.7.5 |pass |
|System kickstart |pass |
|Check for usage of dangerous range of UID/GIDs |pass |
|Incorrect usage of reserved UID/GIDs |pass |
|Compatibility Between iptables and ip6tables |informational |
|VCS repositories |informational |
|Removed options in coreutils binaries |informational |
|Removed options in gawk binaries |informational |
|Removed options in netstat binary |informational |
|GMP library incompatibilities |informational |
|httpd configuration compatibility check |informational |
|File Systems, Partitions and Mounts Configuration Review |informational |
|Sonamebumped libs |informational |
|SonameKept Reusable Dynamic Libraries |informational |
|Removed .so libs |informational |
|Foreign Perl modules |informational |
|YUM |informational |
|Replaced rpms |fixed |
|package downgrades |fixed |
|OpenSSH sysconfig migration content |fixed |
|State of LVM2 services. |fixed |
|Configuration Files to Review |needs_inspection |
|File Lists for Manual Migration |needs_inspection |
|Obsoleted rpms |needs_inspection |
|Packages not signed by CentOS |needs_action |
|Removed rpms |needs_action |
|General |needs_action |
|Content for enabling and disabling services based on CentOS 6 system |needs_action |
---------------------------------------------------------------------------------------------------------------
Tarball with results is stored here /root/preupgrade-results/preupg_results-200613145551.tar.gz .
The latest assessment is stored in directory /root/preupgrade .
Summary information:
We found some potential in-place upgrade risks.
Read the file /root/preupgrade/result.html for more details.
Upload results to UI by command:
e.g. preupg -u http://127.0.0.1:8099/submit/ -r /root/preupgrade-results/preupg_results-*.tar.gz .

Step 5: Importing CentOS 7 PGP key to upgrade centos6 to centos7

We have completed the test and now this is the time to import the CentOS 7 PGP key. So, use the below command to import the key.

rpm --import http://mirror.centos.org/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7

Note: Sometimes you maybe get some errors as downloading failed: invalid data in .treeinfo: No section: ‘checksums’

To bypass these errors,  append CentOS mirror under the mirror list,

mkdir -pv /var/tmp/system-upgrade/base/ /var/tmp/system-upgrade/extras/ /var/tmp/system-upgrade/updates/
echo http://mirror.centos.org/centos/7/os/x86_64/ >> /var/tmp/system-upgrade/base/mirrorlist.txt
echo http://mirror.centos.org/centos/7/extras/x86_64/ >> /var/tmp/system-upgrade/extras/mirrorlist.txt
echo http://mirror.centos.org/centos/7/updates/x86_64/ >> /var/tmp/system-upgrade/updates/mirrorlist.txt

Step 6: Upgrade from CentOS6 to CentOS7

We have performed all the essential steps. Therefore, this is the time to perform the upgrade. Use the below command to start it.

centos-upgrade-tool-cli --network=7 --instrepo=http://vault.centos.org/7.0.1406/os/x86_64/

This process will take time and it also depends on your internet speed. Because it will download the boot image and necessary packages.

After completing the download, It will get the output, Reboot to start to upgrade. So, go ahead and reboot the system. It will take time depending on your system hardware configuration and your previous operating system software packages.

upgrade centos6 to centos7

Note: If you get any errors. Therefore, you can do a force to upgrade. This is not the right way but you can force it. You can find the below command helpful for that.

centos-upgrade-tool-cli --force --network=7 --instrepo=http://vault.centos.org/7.0.1406/os/x86_64/ --cleanup-post

Step 7: After reboot

Your operating system will be upgraded. But, if you get any errors like

/bin/grep: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory
lib-error

Then, you can run the below command,

ln -s /lib64/libpcre.so.1 /lib64/libpcre.so.0

Step 8: Verifying the CentOS version after upgrade centos6 to centos7

You can use the below command to verify the current CentOS version.

cat /etc/centos-release

Output

CentOS Linux release 7.0.1406 (Core)

If everything is fine then your machine will be upgraded to CentOS 7.  That’s it, you have successfully upgraded CentOS 6 to CentOS 7.

Conclusion

In this tutorial, you learned, how to upgrade CentOS6 to CentOS7. In conclusion, you have upgraded your machine from CentOS6 to CentOS7. So, I hope, you understand but if you have any questions, you can ask in the comment section.

If you want to download the CentOS 7 ISO image from the official website then you can visit here, Download CentOS Officially.

You may like to read about 

upgrade centos6 to centos7 | upgrade centos6 to centos7 | upgrade centos6 to centos7 | upgrade centos6 to centos7 | upgrade centos6 to centos7 | upgrade centos6 to centos7 | upgrade centos6 to centos7 | upgrade centos6 to centos7 | upgrade centos6 to centos7 | upgrade centos6 to centos7 | upgrade centos6 to centos7

13 Comments

Leave a Reply

Your email address will not be published.

  1. so… you deleted my comment whiteout even the care to comment/ reply…

    • We do not look at the comment every day. We can check the comments when we have time. You can find my email on the contact page and there you can mail us for a faster response. Thank you.

  2. Αfter exploring a һandful of the bⅼog pօsts on your ᴡeb site,
    I really aⲣpreciate your way of blogging. I
    аdded it to my bookmark webрage list and will be checking back in the
    near future.

  3. I am able to go through the essential steps to run the “centos-upgrade-tool-cli” command. But on the first reboot, it said “systemd-fsck[237]: fsck: errot 2 (No such file or directory) while executing ssck.ext2 for /dev/mapper/vg_root” and it was stuck there and couldn’t boot up.
    Can anyone please help?

    Thanks,
    Tao

    • Indeed very helpful and document up to this stage.
      And now it broke !

    • Error: kernel command-line option rd_NO_LUKS is deprecated, use rd.luks=0 instead

      Solution: If you are able to log in then you can do one thing, remove the crypt module from the dracut and it will stop the initramfs from detecting and mounting that encrypted volumes. You have to change the value in /etc/dracut.conf. Add this value

      omit_dracutmodules+=”crypt”

      And the regenerate the initramfs using the below command
      sudo dracut –force

      Let me know if you are still getting the same error or different.

  4. thanks Hasan for this tuto,

    i have succesfully centos 7 now. but

    # yum update not working now

    a part of the errors :
    Error: Package: gnutls-3.3.29-9.el7_6.x86_64 (installed)
    Requires: libnettle.so.4()(64bit)
    Removing: nettle-2.7.1-8.el7.x86_64 (installed)
    libnettle.so.4()(64bit)
    Updated By: nettle-3.2-2.el6.x86_64 (epel)
    ~libnettle.so.6()(64bit)
    Error: Package: gnutls-3.3.29-9.el7_6.x86_64 (installed)
    Requires: libhogweed.so.2()(64bit)
    Removing: nettle-2.7.1-8.el7.x86_64 (installed)
    libhogweed.so.2()(64bit)
    Updated By: nettle-3.2-2.el6.x86_64 (epel)
    ~libhogweed.so.4()(64bit)
    You could try using –skip-broken to work around the problem
    5:28
    ** Found 27 pre-existing rpmdb problem(s), ‘yum check’ output follows:
    ImageMagick6-libs-6.9.11.44-1.el6.remi.x86_64 has missing requires of libIlmImf.so.6()(64bit)
    ImageMagick6-libs-6.9.11.44-1.el6.remi.x86_64 has missing requires of libcdt.so.4()(64bit)
    ImageMagick6-libs-6.9.11.44-1.el6.remi.x86_64 has missing requires of libgraph.so.4()(64bit)
    ImageMagick6-libs-6.9.11.44-1.el6.remi.x86_64 has missing requires of libgvc.so.5()(64bit)
    cloog-ppl-0.15.7-1.2.el6.x86_64 has missing requires of libgmp.so.3()(64bit)

    • Hi Anes, Please check all your internet connection and look if the IP and DNS setting is perfect. Change the nameserver.

      If you are getting the same problem, then clear the yum cache, yum clean all, followed by yum makecache to refresh it.
      If this doesn’t help, get a new CentOS repository definition file from the official website. As you are using version 6, it has been a while since you installed it, and the repository definitions in /etc/yum.repos.d, It might be pointing to the wrong location to obtain the mirror list.

      And also, Please look to the CentOS Repository Page make sure your /etc/yum.repos.d/CentOS-Base.repo contains URLs that are resolvable and reachable from where you are. Also, look at the list of mirrors returned by this URL – these are the mirrors closest to you. If none of them is reachable, try using a free proxy somewhere to force a different list of mirrors.

  5. Hi Hasan,

    Thanks for your document!
    I have tried your steps to upgrade from Centos 6.10 to 7.x. But I’m getting errors while using below command. Could you please advise on this.

    centos-upgrade-tool-cli –force –network=7 –instrepo=http://vault.centos.org/7.0.1406/os/x86_64/ –cleanup-post


    Downloading failed: Errors were encountered while downloading packages.
    gnupg2-2.0.22-5.el7_5.x86_64: failure: Packages/gnupg2-2.0.22-5.el7_5.x86_64.rpm from cmdline-instrepo: [Errno 14] PYCURL ERROR 22 – “The requested URL returned error: 404 Not Found”
    iwl6000-firmware-9.221.4.1-79.el7.noarch: failure: Packages/iwl6000-firmware-9.221.4.1-79.el7.noarch.rpm from cmdline-instrepo: [Errno 14] PYCURL ERROR 22 – “The requested URL returned error: 404 Not Found”
    lz4-1.8.3-1.el7.x86_64: failure: Packages/lz4-1.8.3-1.el7.x86_64.rpm from cmdline-instrepo: [Errno 14] PYCURL ERROR 22 – “The requested URL returned error: 404 Not Found”
    1:net-snmp-agent-libs-5.7.2-49.el7.x86_64: failure: Packages/net-snmp-agent-libs-5.7.2-49.el7.x86_64.rpm from cmdline-instrepo: [Errno 14] PYCURL ERROR 22 – “The requested URL returned error: 404 Not Found”
    2:xinetd-2.3.15-14.el7.x86_64: failure: Packages/xinetd-2.3.15-14.el7.x86_64.rpm from cmdline-instrepo: [Errno 14] PYCURL ERROR 22 – “The requested URL returned error: 404 Not Found”
    kpartx-0.4.9-133.el7.x86_64: failure: Packages/kpartx-0.4.9-133.el7.x86_64.rpm from cmdline-instrepo: [Errno 14] PYCURL ERROR 22 – “The requested URL returned error: 404 Not Found”
    libkadm5-1.15.1-50.el7.x86_64: failure: Packages/libkadm5-1.15.1-50.el7.x86_64.rpm from cmdline-instrepo: [Errno 14] PYCURL ERROR 22 – “The requested URL returned error: 404 Not Found”
    libtasn1-4.10-1.el7.x86_64: failure: Packages/libtasn1-4.10-1.el7.x86_64.rpm from cmdline-instrepo: [Errno 14] PYCURL ERROR 22 – “The requested URL returned error: 404 Not Found”

    • You have to check your Internet connection and also if you are using any proxy server. Please let me know if you still getting the problem with the screenshot on email sahilatlinuxgurus.in.