I just recently had the job of upgrading a clients CentOS server from 6.5 to 7.2, this can be a little daunting at first but running some tests first in a VM worked well so I was OK to go. Here’s how I did it.

Please note that major upgrades can cause data loss, or things can go wrong so before you start make a backup of your server. Then if things go wrong you can revert to save point

WARNING! Do not use this method to upgrade from CentOS 6.7 or higher as several system critical packages are of a higher version number than they are in centos 7 so those do not get upgraded correctly. This renders the system broken and several system tools non-functional. You will not be able to login in or use networking.

Also CentOS 6.6 fails now with the upgrade with error “Downloading failed: invalid data in .treeinfo: No section: ‘checksums'” so this is also broken on CentOS 6.6 now and can ONLY be done on CentOS 6.5.

Step 1: Backup and update

In the past to update like this you had to reinstall the new CentOS then restore all your programs and data but now with CentOS 7 we can do an inlace upgrade, that being said thing can still go wrong so first make a backup of your sever once that is done we can proceed.

After you have made your backup run an update

Since the release of CentOS 6.7 and 6.8 this method is broken. If you are on CentOS 6.6 or lower then DO NOT UPDATE YOUR SYSTEM BEFORE UPGRADING this will break the upgrade process. To check your version do

CentOS 6.6 fails on upgrade to. Use this method at your own risk. The best solution is to fresh install.
If your release is CentOS 6.6 or lower then you may proceed. If you have CentOS 6.7 or 6.8 then the only way to upgrade to CentOS 7 will be to do a fresh install.

I had problems with getting Apache and MySQL and PHP to start after the upgrade so I would remove them now and reinstall them after the upgrade so in a terminal

Don’t forget to save your configs files to restore them after the upgrade.

Step 2: Add the prerequisites

First thing to do is install the upgrade repo so as the root user you need to make a new file in ‘/etc/yum.repos.d/upgradetool.repo’ I use nano but you can use whatever text editor you are used to:

Then add these line to the file

Once done save this file. First we are going to install the pre-upgrade tool and run it to show us any potential problems, so in your terminal

Before doing this we have to  openscap-1.0.8-1.0.1 thanks to Alan for this so first


Step 3: Verifying the upgrade

Once that has installed run the pre-upgrade check to look for any potential problems, now you don’t have to do this be it’s better to check than not to. So in your terminal

Which gives you a warning and confirmation like

So as we have already make a backup we would type ‘y’ to proceed. Next it will run some checks and give us a out like:

Now you can read the file with the potential upgrade risks but I didn’t all seemed to go well but it doesn’t do any harm as you might have custom programs that will cause problems as all mine were installed from the repos I just went on to the next step which is to import the CentOS 7 repo key so in your terminal

Step 4: Starting the upgrade

Then we have to run the upgrade tool, which doesn’t do the upgrade it just downloads the updates needed to do the upgrade, that happens when we reboot the server so in your terminal

Step 5: Reboot the server

Once that has finished we are ready to do the upgrade so bit can be a bit hairy because if you are doing this on a remote server then you might not be able to see the boot process unless you have access a online console. The applying of updates will happen while the server is booting and can take 10-15 minutes so if you are doing this blind it can be a bit of a nail bitting moment, but if you have already practiced this like I did in a VM then you should have confidence in it working OK. That said if your machine doesn’t come back online in 30 minutes then you may need to restore from your backup (you did do that backup now didn’t you?). So in your terminal

After waiting for about 10 minutes try logging in, if you can’t try again in 10 more minutes and if you still can’t in 30 minutes then you may have to restore to your save point and start again.

Step 6: Check for post upgrade problems

OK if you are still reading this you made it and have successfully logged into your server lets check our version with

And you should see

Run a update

if you get errors saying  ‘libpcre.so.0 is missing’ then try reinstalling pcre.

and if that didn’t work then try symlinking the newer pcre file to the old one with

Reinstall all Apache, MySQL and PHP. Now I didn’t do this, I took the opportunity to install Nginx and MariaDB and compile my own PHP so I will do this in the next few posts.

I have to go now so I hope this has helped someone.

If you want to leave a comment please do and I will try my best at answering.

Watch on youtube: Upgrading CentOS 6.5 to 7.2

  • Pingback: Upgrading MySQL to MariaDB in CentOS 7.2 | Shaun Freeman()

  • Dmitry Shultz

    Everything went as you said except of SELinux got activated by the something (I was not able to login at all). Booted with selinux=0 kernel param and it helped.
    Thanks for putting this together!

    • Thanks Dmitry, I am glad my post helped. Thanks for the heads up with the SELinux problem you had, glad you worked it out. I normally don’t have SELinux enabled but didn’t have that problem of it getting enabled on update. Very odd and curious of how it happened too. I am glad it didn’t happen to me as I was working on a remote server without access to a emergency console if anything went wrong. Thanks for sharing your experience.

  • asle

    I am running centos 6.7 on a Digital Ocean Droplet. All the commands are ok until I am ready to do the upgrade. It shows a lot of messages and in the end it says:

    setting up system for upgrade
    grubby fatal error: unable to find a suitable template
    Finished. Reboot to start upgrade.

    So I reboot but nothing happens. What is this “grubby fatal error”? Maybe it is not possible to upgrade a VPS? Does this have something to do with the kernel?

    • Thanks @disqus_r8T3w5v6Ba:disqus. I have not used Digital Ocean VPS before, I use Vultr and test my VPS upgrades via Virtual Machine, but in this case my client had their CentOS server on Microsoft Azure to manage their VPS.

      It is possible to upgrade on a VPS but different VPS host have different setups or a little hacking is involed to do the upgrade. I have been upgrading linux on VPS for a few years now and never had a major problem with it, I normally use Ubuntu for my servers but in this case I had no choice as my client had CentOS installed.

      It looks like Digital Ocean are not using GRUB on their servers so you will have to use a hack as a workaround to your problem. Anyway I did a little googling and found this article that sounds like the problem you have http://www.itekhost.net/grubby-fatal-error/ hope this article solves your problem.

      • asle

        Hi Shaun,
        I read the article about grub and deleted the files. This time I did not get the “grubby fatal error” but this message:

        ….setting up system for upgrade
        Finished. Reboot to start upgrade.
        ➜ ~ sudo reboot

        After a reboot I still have Centos 6.7 so it seems nothing happens after the reboot.

        ➜ ~ cat /etc/redhat-release
        CentOS release 6.7 (Final)

        • Hi Asle
          You might have to reinstall to CentOS 7 instead not sure if it is possible to upgrade on a Digital Ocean droplet. Looks like they have a different setup on their VPS than what I am used to so a reinstall to CentOS 7 would be the route to take. It will be quicker in the long run than try to hack round it.

          One way to do this would be to setup a new droplet with CentOS 7 and install all you need on the new one then transfer all web data across from the old one and when you have verified everything is as it should shutdown the old droplet and make sure all DNS routes to the new server. Sorry can’t seem to see a quicker solution to this one.

          • asle

            I think you are right on this case. I haven’t tested this on a Linode.com server but will test it there also.

  • Pingback: Basic Linux | Plesk Issues and fixes.()

  • Joe Brouhard

    Just ran into this error after testing out the upgrade path: libsasl2.so.2: cannot open shared object file: No such file or directory

    after attempting yum update.

    • Hi @joebrouhard:disqus try reinstalling libsasl2 or what depends on it first, or try this https://www.centos.org/forums/viewtopic.php?t=6086 solution.

    • Michael O’Riley

      I ran into the same error and running this line in the terminal worked for me:

      ln -s /usr/lib64/libsasl2.so.3.0.0 /usr/lib64/libsasl2.so.2

  • Michael O’Riley

    When I upgraded from 6 to 7 I noticed there was network connectivity issues, which were resolved when I opened ifcfg-eth0 and changed the boot protocol to dhcp:

    nano /etc/sysconfig/network-scripts/ifcfg-eth0


    F2 to save

    • Michael O’Riley

      PS Thank you Shaun, you have the most comprehensive updating guide I could find on the internet. I was able to upgrade my VPS remotely with all my files intact!!

  • Alan

    Before the step 3 you will need to install the openscap-engine-sce package. Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1304772 https://rhn.redhat.com/errata/RHBA-2016-1022.html

  • Alan

    Sorry, ignore the previous comment, what you will need this is:

    Before the step 2 you will need to install:
    yum erase openscap
    yum install http://dev.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm

    Ref: https://www.centos.org/forums/viewtopic.php?t=59763#p252751

    • Thanks Alan, when I did this there wasn’t this bug. I will update this to reflect this issue.
      This is broken now in CentOS 6.7 and higher

      • Teamgeist Delpiero

        i have error on step 4 (upgrade)
        error is “invalid data in .treeinfo: No option ‘upgrade’ in section: ‘images-x86_64′”
        that i erase previous openscap and install openscap-1.0.8-1.0.1.el6.centos.x86_64 befor on step2.How to solved it?

        • If you get this error it means you can’t upgrade this way. You will have to do a fresh install.

  • Batayan Chakma

    Hi Shaun,
    Thanks for the useful video. I was just wondering if you have any step by step instruction for offline upgrade. I am particularly interested into upgrade from CentOS 6.6 to 6.9 on a system having no internet connection. What could be the best approach to do that? Also please note that I have some custom rms installed on the current 6.6 system.

    Thanks in advance,