How to Upgrade CentOS 7 to CentOS 8

In this article, you will learn how to upgrade CentOS 7 to CentOS 8. The steps described herein do not depict the official upgrade and this should not be applied to a production server yet.

Step 1: Install the EPEL Repository

To start off, install the EPL repository by running:

# yum install epel-release -y
Install EPEL Repo in CentOS 7
Install EPEL Repo in CentOS 7

Step 2: Install yum-utils Tools

After successfully installing EPEL, install yum-utils by running the command below.

# yum install yum-utils
Install yum-utils in CentOS 7
Install yum-utils in CentOS 7

Thereafter, you need to resolves RPM packages by executing the command.

# yum install rpmconf
# rpmconf -a
Keep Default RPM Settings
Keep Default RPM Settings

Next, perform a clean-up of all the packages you don’t require.

# package-cleanup --leaves
# package-cleanup --orphans
Clean RPM Packages
Clean RPM Packages

Step 3: Install the dnf in CentOS 7

Now install dnf package manager which is the default package manager for CentOS 8.

# yum install dnf
Install dnf in CentOS 7
Install dnf in CentOS 7

You also need to remove the yum package manager using the command.

# dnf -y remove yum yum-metadata-parser
# rm -Rf /etc/yum
Remove Yum in CentOS 7
Remove Yum in CentOS 7

Step 4: Upgrading CentOS 7 to CentOS 8

We are now ready to upgrade CentOS 7 to CentOS 8, but before we do so, upgrade the system using the newly install dnf package manager.

# dnf upgrade
Upgrade CentOS 7
Upgrade CentOS 7

Next, install CentOS 8 release package using dnf as shown below. This will take a while.

# dnf install http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/centos-repos-8.2-2.2004.0.1.el8.x86_64.rpm http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/centos-release-8.2-2.2004.0.1.el8.x86_64.rpm http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/centos-gpg-keys-8.2-2.2004.0.1.el8.noarch.rpm

Next, upgrade the EPEL repository.

dnf -y upgrade https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
Upgrade EPEL Repository
Upgrade EPEL Repository

After successfully upgrading the EPEL repository, remove all the temporary files.

# dnf clean all

Remove the old kernel core for CentOS 7.

# rpm -e `rpm -q kernel`

Next, be sure to remove conflicting packages.

# rpm -e --nodeps sysvinit-tools

Thereafter, launch the CentOS 8 system upgrade as shown.

# dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
CentOS 8 System Upgrade
CentOS 8 System Upgrade

Step 5: Install the New Kernel Core for CentOS 8

To install a new kernel for CentOS 8, run the command.

# dnf -y install kernel-core
Install Kernel in CentOS 8
Install Kernel in CentOS 8

Finally, install CentOS 8 minimal package.

# dnf -y groupupdate "Core" "Minimal Install"

Now you can check the version of CentOS installed by running.

# cat /etc/redhat-release
Check CentOS Version
Check CentOS Version

Read Also: How to Set Up Automatic Updates for CentOS 8

Conclusion

This article concludes on how you can upgrade from CentOS 7 to CentOS 8. We hope you found this insightful.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

122 thoughts on “How to Upgrade CentOS 7 to CentOS 8”

  1. Hi Team,

    # sudo dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync --best
    Last metadata expiration check: 0:05:30 ago on Tue 13 Oct 2020 12:23:13 PM IST.
    Error:
     Problem: The operation would result in removing the following protected packages: dnf
    

    I did below, still no luck. There is no value under /etc/yum/protected.d/.

    # rm /etc/dnf/protected.d/dnf.conf
    

    Please help

    Reply
  2. Hi,

    I tried to follow this guide to upgrade from centos7 to 8, I didn’t manage with the upgrade but most of the packages are in el8, I am also having problems installing packages with the below error:

    Total                                           1.4 MB/s |  35 MB     00:25     
    Running transaction check
    Error: transaction check vs depsolve:
    (flatpak-selinux = 1.6.2-3.el8_2 if selinux-policy-targeted) is needed by flatpak-1.6.2-3.el8_2.x86_64
    rpmlib(RichDependencies) <= 4.12.0-1 is needed by flatpak-1.6.2-3.el8_2.x86_64
    To diagnose the problem, try running: 'rpm -Va --nofiles --nodigest'.
    You probably have corrupted RPMDB, running 'rpm --rebuilddb' might fix the issue.
    The downloaded packages were saved in the cache until the next successful transaction.
    You can remove cached packages by executing 'dnf clean packages'.
    

    Kindly assist.
    Regards

    Reply
    • Do this:

      1. Try to repair database as suggested:

      # rpm --rebuilddb
      

      2. If it still does not work, reinstall flatpak packages:

      # dnf reinstall flatpak*
      

      3. If it still does not work, remove flatpak packages and install them again:

      # dnf remove flatpak*
      

      4. If dnf does not work, use rpm:

      # rpm -e flatpak flatpak-selinux
      

      5. If there are dependecies, remove with them:

      # rpm -e flatpak flatpak-selinux [anotherpackages]
      

      6. If you are sure what you are doing, use:

      # rpm -e --nodeps 
      
      Reply
  3. The latest packages for core:

    # dnf upgrade -y http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/{centos-release-8.2-2.2004.0.1.el8.x86_64.rpm,centos-gpg-keys-8.2-2.2004.0.1.el8.noarch.rpm,centos-repos-8.2-2.2004.0.1.el8.x86_64.rpm}

    Reply
  4. When trying to group update about “Core” “Minimal Install“, centos system has error in yum.

    Can I get the solution?

    Environment
    – CentOS 7.5

    ** Error Messages

    # dnf groupupdate "Core" "Minimal Install"
    ...
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :     
      Installing       : yum-4.2.17-7.el8_2.noarch     
    Error unpacking rpm package yum-4.2.17-7.el8_2.noarch
      Verifying        : yum-4.2.17-7.el8_2.noarch  
    
    Failed:
      yum-4.2.17-7.el8_2.noarch
    
    Error: Transaction failed
    
    Reply
  5. # dnf -y --releasever=8 --setopt=deltarpm=false --allowerasing --best distro-sync
    Repository extras is listed more than once in the configuration
    Repository centosplus is listed more than once in the configuration
    CentOS-8 - Updates Sources          
    CentOS-8 - cr                        
    CentOS-8 - Base Sources              
    CentOS-8 - Base   
    Failed to synchronize cache for repo 'updates-source', ignoring this repo.
    Failed to synchronize cache for repo 'cr', ignoring this repo.
    Failed to synchronize cache for repo 'base-source', ignoring this repo.
    Failed to synchronize cache for repo 'base', ignoring this repo.
    Failed to synchronize cache for repo 'updates', ignoring this repo.
    Last metadata expiration check: 0:09:25 ago on Sun 16 Aug 2020 10:30:35 AM CDT.
    Error: 
     Problem: The operation would result in removing the following protected packages: dnf
    
    Reply
      • I am also getting the same error, I have no repo issues, I tried removing dnf from /etc/dnf/protected.d/ and /etc/yum/protected.d/. But no luck

        # dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
        Last metadata expiration check: 0:04:49 ago on Tue 13 Oct 2020 12:45:13 PM IST.
        Error:
         Problem: The operation would result in removing the following protected packages: dnf
        
        Reply
  6. These docs should be removed as they DO NOT and WILL NOT work. Even on a clean Centos 7 system, this process will fail because of dependencies.

    This procedure will break your system. It will at best, leave you spinning on the dependency check that will never complete (8+ hours and it didn’t complete), or leave you with a difficult to resolve circular dependency with python or GCC.

    There are ways to unbrick a system by manually downloading and manually extracting packages to jumpstart a DNF reinstallation of broken packages, but it’s not worth it.

    Reply
  7. Hi James,

    Thank you for the thoughtful article.

    After following this closely, I was was able to upgrade with no issue — just an old python 3.6 repo that I removed, based on the conflict report.

    Very much enjoying the new Web Cockpit.

    Thanks again!

    Trevor

    Reply
  8. I’ve got the following error on distro-sync step:

    Error: transaction check vs depsolve:
    (gcc >= 8 with gcc < 9) is needed by annobin-8.90-1.el8.0.1.x86_64
    rpmlib(RichDependencies) <= 4.12.0-1 is needed by annobin-8.90-1.el8.0.1.x86_64
    (annobin if gcc) is needed by redhat-rpm-config-122-1.el8.noarch
    rpmlib(RichDependencies) <= 4.12.0-1 is needed by redhat-rpm-config-122-1.el8.noarch
    To diagnose the problem, try running: 'rpm -Va --nofiles --nodigest'.
    You probably have corrupted RPMDB, running 'rpm --rebuilddb' might fix the issue.
    The downloaded packages were saved in cache until the next successful transaction.
    You can remove cached packages by executing 'dnf clean packages'.
    

    Case anyone has ideas about how to fix it

    Reply
    • I’ve had the same problem and resolved it with:

      # dnf remove perl
      # dnf remove python3
      

      then

      # dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
      

      and reinstall perl (if necessary)

      Reply
    • Dude, these “howtos” arrive every time there is a major version update and they NEVER work for real installations.

      1) No Centos system I have ever run will let you remove any kernel, because, “IT IS THE KERNEL” and it refuses to do so using yum, or dnf.

      2) Even when you skip all of that, and just jump to the upgrade of installed packages, you end up needing to actually remove everything on the system, and then basically start from a vanilla install, and that probably still won’t work.

      I ALWAYS end up just fully reinstalling using media, after backing up or migrating the necessary bits from the current install.

      These tutorials are always worthless in the real world.

      I believe these guys are working with a fedora or bleeding-edge centos development branch with certain features turned off, which are never disclosed.

      Reply
      • Also, one of the “updated” comments from a reader back in the spring indicated that they had some issues with python36-* and just “removed it” to continue. Well, I just figured I would remove the python packages that were also proving to be troublesome since this was just a development hypervisor for my openshift cluster and some other stuff. (I.E. all the important stuff is on the hardware raid built into the chassis, and I use installation ssds to run the actual OS.)

        So I just wanted to see how far I would get, and maybe for possibly the third major release in a row won’t force full vanilla install at some point.

        Welp, sure enough, once I started removing python3 stuff that it was complaining about, dnf (python app) started giving errors about not being able to find named module, etc….

        However, if you remember from earlier steps, you have already fully removed “yum” in place of “dnf.”

        However, I have also come across this exact situation when migrating from CentOS 6 to CentOS 7 before they came up with the nifty “in place update” tooling that made it so easy and less problematic.

        So yup, these articles are always a trip, because they never really work.

        I have to assume that just like the Linux “gurus” of old, where the world “worked on their box” but when you tried to find out how to build the world on yours, you were always left floating in space as they confidently indicated that “it works on their box….”

        I think these articles are based on a minimum-proof-of-concept that no one is actually running. (Like making some minimalist install that would require so much removal of items and packages to get back to, that you may as well just install fully with new media.)

        Reply
      • “1) No Centos system I have ever run will let you remove any kernel, because, “IT IS THE KERNEL” and it refuses to do so using yum, or dnf.”

        Well, use rpm and put --nodeps and you can remove the kernel. But yes, if something goes wrong, you will end up bricking the system, there will be no kernel to boot into. I was able to upgrade to 8.2, had to rpm -e --nodeps the kernel; also had to remove devel packages – what I did was list the devel packages that were being removed into a file and reinstall all of them after the base upgrade was finished; had to do this for about 25 packages. Also, the upgrade usually works only at minimal install level, had to then group install development tools, systems tools, security tools, etc etc. A real pain, but possible.

        Reply
        • Thanks for the update, but I have been holding off getting back onto that test hypervisor because I have to basically re-install python because now dnf doesn’t know how to run using python 2 or whatever is currently installed.

          There is always some “bricking” command included in these tutorials. I was just wondering if that were still the case, and sure enough, once I got over the hurdles referenced by the other guys, I ended up with a system that can’t install anything else, because I have uninstalled python3 and yum is gone so nothing cares about python2 or whatever is currently installed. LOL…

          Reply

Leave a Reply to James Kiarie Cancel reply

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.