How to Upgrade CentOS 7 to CentOS 8 Linux

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-linux-repos-8-2.el8.noarch.rpm,centos-linux-release-8.4-1.2105.el8.noarch.rpm,centos-gpg-keys-8-2.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.

170 thoughts on “How to Upgrade CentOS 7 to CentOS 8 Linux”

  1. This guide while has good intentions should simply not be followed. It doesn’t cover handling dependencies and leaves out a few steps such as kernel modules being updated correctly. Historically, Red Hat has not pushed the idea that major upgrades are supported, and while it is possible, it’s only worth chasing if these steps are properly documented, which they clearly are not in this article.

    Reply
  2. On the last command, I added --skipbroken, because I could not resolve all dependencies.

    My question is, when you reboot, which kernel is supposed to boot up the system? With the command uname -r I still get 3.10.0-1160.36.2.el7.x86_64, old version.

    With:

    # dnf list installed kernel
    

    Installed Packages
    kernel.x86_64 3.10.0-1160.36.2.el7 @System
    kernel.x86_64 4.18.0-305.12.1.el8_4 @baseos

    Reply
      • Thanks for answering!

        What about the conflicts? How can I solve them because I cannot run update/upgrade commands?

        Here is part of what I get:

        file /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/upload.cpython-36.opt-1.pyc from install of platform-python-setuptools-39.2.0-6.el8.noarch conflicts with file from package python3-setup tools-39.2.0-10.el7.noarch
        file /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/upload.cpython-36.pyc from install of platform-python-setuptools-39.2.0-6.el8.noarch conflicts with file from package python3-setuptools- 39.2.0-10.el7.noarch
        file /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/upload_docs.cpython-36.opt-1.pyc from install of platform-python-setuptools-39.2.0-6.el8.noarch conflicts with file from package python3- setuptools-39.2.0-10.el7.noarch
        file /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/upload_docs.cpython-36.pyc from install of platform-python-setuptools-39.2.0-6.el8.noarch conflicts with file from package python3-setupt ools-39.2.0-10.el7.noarch
        file /usr/lib64/libgdbm_compat.so.4.0.0 from install of gdbm-libs-1:1.18-1.el8.x86_64 conflicts with file from package gdbm-1.10-8.el7.x86_64

        Reply
  3. UPDATE: I cannot recommend this upgrade method. I have made some progress, but am still in dependency hell. I have done 'yum --best --allowerasing -x upgrade a* b*' and so on, iterating through the alphabet and adding packages that break the process.

    I still have a list I can’t upgrade, and still have a list that prevents distsync. I am concerned that any reboot will completely hose the system, especially as I run headless. I am on the verge of major surgery (removing mariadb, for example), but even then a dnf upgrade is required but I cannot do so because it is protected (and would require erasing). At this point, I need to sink $$$ into the project, build a completely new system, and migrate each package and config over piece by piece. Grr.

    Reply
    • The current output of distsync:

      rror: transaction check vs depsolve:
      (gcc >= 8 with gcc < 9) is needed by annobin-9.50-1.el8.x86_64
      rpmlib(RichDependencies) = 3:10.3.27 if mariadb) is needed by mariadb-connector-c-3.1.11-2.el8_3.x86_64
      (mariadb-connector-c-config = 3.1.11-2.el8_3 if mariadb-connector-c-config) is needed by mariadb-connector-c-3.1.11-2.el8_3.x86_64
      rpmlib(RichDependencies) <= 4.12.0-1 is needed by mariadb-connector-c-3.1.11-2.el8_3.x86_64
      (ipa-selinux if selinux-policy-targeted) is needed by ipa-common-4.9.2-3.module_el8.4.0+780+c53619b9.noarch
      rpmlib(RichDependencies) <= 4.12.0-1 is needed by ipa-common-4.9.2-3.module_el8.4.0+780+c53619b9.noarch
      (annobin if gcc) is needed by redhat-rpm-config-125-1.el8.noarch
      rpmlib(RichDependencies) <= 4.12.0-1 is needed by redhat-rpm-config-125-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'.

      Trying to install via DNF gives error "none of the providers can be installed" e.g:
      – package ipa-common-4.9.2-3.module_el8.4.0+780+c53619b9.noarch requires (ipa-selinux if selinux-policy-targeted), but none of the providers can be installed

      Reply
  4. In the last step:

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

    I get the following error:

    Running transaction check
    Error: transaction check vs depsolve:
    (mariadb >= 3:10.3.27 if mariadb) is needed by mariadb-connector-c-3.1.11-2.el8_3.x86_64
    (mariadb-connector-c-config = 3.1.11-2.el8_3 if mariadb-connector-c-config) is needed by mariadb-connector-c-3.1.11-2.el8_3.x86_64
    rpmlib(RichDependencies) = 1.20 or dhclient) is needed by dracut-network-049-135.git20210121.el8.x86_64
    rpmlib(RichDependencies) <= 4.12.0-1 is needed by dracut-network-049-135.git20210121.el8.x86_64

    I also tried the following command, but that didn't work either. Help because I'm stuck here.

    # dnf -y groupupdate "Core" "Minimal Install" --allowerasing
    
    Reply
  5. When running the distrosync, I get the following error(s):

    Running transaction check
    Error: transaction check vs depsolve:
    (gcc >= 8 with gcc < 9) is needed by annobin-9.50-1.el8.x86_64
    rpmlib(RichDependencies) = 3:10.3.27 if mariadb) is needed by mariadb-connector-c-3.1.11-2.el8_3.x86_64
    (mariadb-connector-c-config = 3.1.11-2.el8_3 if mariadb-connector-c-config) is needed by mariadb-connector-c-3.1.11-2.el8_3.x86_64
    rpmlib(RichDependencies) = 1.20 or dhclient) is needed by dracut-network-049-135.git20210121.el8.x86_64
    rpmlib(RichDependencies) <= 4.12.0-1 is needed by dracut-network-049-135.git20210121.el8.x86_64
    (flatpak-selinux = 1.8.5-3.el8 if selinux-policy-targeted) is needed by flatpak-1.8.5-3.el8.x86_64
    rpmlib(RichDependencies) <= 4.12.0-1 is needed by flatpak-1.8.5-3.el8.x86_64
    (ipa-selinux if selinux-policy-targeted) is needed by ipa-common-4.9.2-3.module_el8.4.0+780+c53619b9.noarch
    rpmlib(RichDependencies) <= 4.12.0-1 is needed by ipa-common-4.9.2-3.module_el8.4.0+780+c53619b9.noarch
    (annobin if gcc) is needed by redhat-rpm-config-125-1.el8.noarch
    rpmlib(RichDependencies) <= 4.12.0-1 is needed by redhat-rpm-config-125-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'.

    For these "needed by ” is it safe to remove (and possibly reinstall) those to run the distrosync? Or have I screwed something up?

    Reply
    • # dnf remove openssl
      # dnf remove python3
      # dnf remove perl
      

      and try again. Basically, you need to get rid of all dependencies of the packages I posted above.

      Reply
      • How would this work? Removing openssl via dnf would want to remove dnf itself, which would be needed for the next step (even if it would remove the running program).

        Reply
  6. This is now giving me some unresolved packages and not letting me continue. But these steps also had me remove my kernel beforehand – so I appear to now be without a kernel, and unable to upgrade!? RPM commands now fail with some non-descript message about a repo (doesn’t tell me which one) being configured wrong. I think I’ve hosed my system…

    Reply
  7. Thanks! This was really helpful, and also had a very annoying bug.

    You only instruct to install `kernel-core`, while I think probably everyone will also need to install `kernel-modules`. I followed the instructions to upgrade my remote VPS, rebooted and there was no network!! Turns out the drivers are actually in the kernel-modules rpm. Ofc installing anything with a broken NIC driver is very painful. So, I pasting this to hopefully save someone else that pain.

    Thanks!

    Reply
  8. Thanks for the guide.

    Step #4: the mirror URL should be:
    dnf install http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/{centos-linux-repos-8-2.el8.noarch.rpm,centos-linux-release-8.4-1.2105.el8.noarch.rpm,centos-gpg-keys-8-2.el8.noarch.rpm}

    Reply
  9. Can any guide if have a solution for this issue

    Running scriptlet: libwbclient-4.13.3-3.el8.x86_64 1213/1213
    Running scriptlet: kernel-core-4.18.0-305.7.1.el8_4.x86_64 1213/1213

    Broadcast message from [email protected]local (Fri 2021-07-09 19:37:35 IST):

    dracut[27540]: Can’t write to /boot/301e98982ddb4aa99dc45bc92cc698d3/4.18.0-305.7.1.el8_4.x86_64: Directory /boot/301e98982ddb4aa99dc45bc92cc698d3/4.18.0-305.7.1.el8_4.x86_64 does not exist or is not accessible.

    Message from [email protected] at Jul 9 19:37:35 …
    dracut:Can’t write to /boot/301e98982ddb4aa99dc45bc92cc698d3/4.18.0-305.7.1.el8_4.x86_64: Directory /boot/301e98982ddb4aa99dc45bc92cc698d3/4.18.0-305.7.1.el8_4.x86_64 does not exist or is not accessible.
    Can’t write to /boot/301e98982ddb4aa99dc45bc92cc698d3/4.18.0-305.7.1.el8_4.x86_64: Directory /boot/301e98982ddb4aa99dc45bc92cc698d3/4.18.0-305.7.1.el8_4.x86_64 does not exist or is not accessible.
    warning: %posttrans(kernel-core-4.18.0-305.7.1.el8_4.x86_64) scriptlet failed, exit status 1

    Error in POSTTRANS scriptlet in rpm package kernel-core
    Running scriptlet: authselect-libs-1.2.2-2.el8.x86_64 1213/1213
    Running scriptlet: httpd-2.4.37-39.module_el8.4.0+778+c970deab.x86_64 1213/1213
    Running scriptlet: authselect-compat-1.2.2-2.el8.x86_64 1213/1213
    Running scriptlet: tuned-2.15.0-2.el8_4.1.noarch 1213/1213
    Running scriptlet: microcode_ctl-4:20210216-1.20210525.1.el8_4.x86_64 1213/1213
    /usr/lib/dracut/modules.d/40network/module-setup.sh: line 33: warning: command substitution: ignored null byte in input
    /usr/lib/dracut/modules.d/40network/module-setup.sh: line 33: warning: command substitution: ignored null byte in input
    /usr/lib/dracut/modules.d/40network/module-setup.sh: line 33: warning: command substitution: ignored null byte in input
    /usr/lib/dracut/modules.d/40network/module-setup.sh: line 33: warning: command substitution: ignored null byte in input

    Reply

Leave a Reply to kiran Bhoir 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.