How to Upgrade CentOS 7 to CentOS 8 Linux

In this article, you will learn how to upgrade CentOS 7 to CentOS 8.5 release. 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 resolve 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 the 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://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/{centos-linux-repos-8-3.el8.noarch.rpm,centos-linux-release-8.5-1.2111.el8.noarch.rpm,centos-gpg-keys-8-3.el8.noarch.rpm}

Note: CentOS 8 is dead and all the repos have been moved to vault.centos.org.

Install CentOS 8 Release Packages
Install CentOS 8 Release Packages

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`
Remove Old CentOS 7 Kernel
Remove Old CentOS 7 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

Note: If you get errors about conflicting packages, for example in my case there were conflicts about the existing python36-rpmconf package. I removed this package, similarly if you get any conflicts just remove those packages and try running the above upgrade command.

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

If you see the above output, I have successfully upgraded from CentOS 7 to CentOS 8.5 release.

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 read this far, tweet to the author to show them you care. Tweet a thanks
James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

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

  1. root@cerebro ~# dnf clean all
    71 files removed

    root@cerebro ~# rpm -e `rpm -q kernel`
    package `rpm is not installed
    package kernel` is not installed

    root@cerebro ~# rpm -e –nodeps sysvinit-tools

    root@cerebro ~# dnf -y –releasever=8 –allowerasing –setopt=deltarpm=false distro-sync
    Extra Packages for Enterprise Linux 8 – x86_64 16 MB/s | 11 MB 00:00
    CentOS Linux 8 – BaseOS 6.0 MB/s | 4.6 MB 00:00
    ELRepo.org Community Enterprise Linux Repository – el7 167 kB/s | 296 kB 00:01
    Nux.Ro RPMs for general desktop use 2.6 MB/s | 4.2 MB 00:01
    Extra Packages for Enterprise Linux Modular 8 – x86_64 1.3 MB/s | 979 kB 00:00
    Copr repo for snapcore-el7 owned by ngompa 46 kB/s | 27 kB 00:00
    CentOS Linux 8 – AppStream 1.9 MB/s | 8.4 MB 00:04
    CentOS Linux 8 – Extras 238 kB/s | 10 kB 00:00
    Error:
    Problem: The operation would result in removing the following protected packages: kernel

    How to fix it now?

    Reply
  2. THIS IS NOT A SUPPORTED METHOD TO UPGRADE !!

    Do NOT follow this or any other ‘upgrade‘ steps you find, as it will most likely fail unless you’re on a brand new system with almost nothing installed/configured to it, and you’ll end up with a very crippled machine that may not survive a reboot again without a full re-install.

    THIS IS NOT A SUPPORTED METHOD TO UPGRADE !!

    Reply
  3. I failed below:

    # yum install rpmconf
    

    It complained python conflict:

    ...
    file /usr/lib64/python3.6/xml/sax/__pycache__/xmlreader.cpython-36.pyc from install of python3-libs-3.6.8-18.el7.x86_64 conflicts with file from package python36u-libs-3.6.8-1.el7.ius.x86_64

    Reply
    • The kernel used for the server while it is running (on power) is in the RAM already. So even if you delete the rpm package of the Linux kernel (or any other running application, e.g. the ftp package on a running ftp server ) the server still is running BUT now you could not reboot it, because, after the reboot, the Linux kernel would not be found anywhere to be loaded in the RAM.

      So when the steps of the article are done, your server will still run with a kernel of centos7.9, and after a reboot, it will start with the kernel of 8.1, I hope I say it correctly. The article should have mentioned in the end to do a reboot.

      Reply
  4. Running transaction check
    Error: transaction check vs depsolve:
    (NetworkManager >= 1.20 or dhclient) is needed by dracut-network-049-191.git20210920.el8.x86_64
    rpmlib(RichDependencies) <= 4.12.0-1 is needed by dracut-network-049-191.git20210920.el8.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 cache until the next successful transaction.
    You can remove cached packages by executing 'dnf clean packages'.

    Reply
      • @ravi this command doesn’t help. I have the same issue as @fredo

        Firstly, yum has already been removed in one of the previous steps. Secondly, dracut-network is not installed and can’t be removed with either rpm or dnf.

        Reply
    • @Fredo I fixed the issue by running `rpm -Va --nofiles --nodigest` and removing all the packages with missing dependencies.

      In my case:

      # rpm -e kexec-tools
      # rpm -e python36-rpmconf-1.0.22-1.el7.noarch rpmconf-1.0.22-1.el7.noarch
      
      Reply
  5. dnf -y groupupdate "Core" "Minimal Install"
    Last metadata expiration check: 0:09:42 ago on Tuesday 23 November 2021 11:09:26 AM IST.

    No match for group package “rhc”
    Error:
    Problem 1: package dracut-049-191.git20210920.el8.x86_64 requires systemd >= 239-23, but none of the providers can be installed
    - package systemd-239-51.el8.i686 obsoletes systemd < 229-5 provided by systemd-219-78.el7_9.3.x86_64
    - cannot install both systemd-239-51.el8.x86_64 and systemd-219-78.el7_9.3.x86_64
    - package systemd-239-51.el8.x86_64 obsoletes systemd = 049-129, but none of the providers can be installed
    - package systemd-sysv-219-78.el7_9.3.x86_64 requires systemd = 219-78.el7_9.3, but none of the providers can be installed
    - conflicting requests
    - problem with installed package systemd-sysv-219-78.el7_9.3.x86_64

    Problem 2: package python3-hawkey-0.63.0-3.el8.x86_64 requires librpm.so.8()(64bit), but none of the providers can be installed
    - package python3-hawkey-0.63.0-3.el8.x86_64 requires librpmio.so.8()(64bit), but none of the providers can be installed
    - package python3-dnf-plugins-core-4.0.21-3.el8.noarch requires python3-hawkey >= 0.46.1, but none of the providers can be installed
    - cannot install both rpm-libs-4.14.3-19.el8.x86_64 and rpm-libs-4.11.3-46.el7_9.x86_64
    - package dnf-plugins-core-4.0.21-3.el8.noarch requires python3-dnf-plugins-core = 4.0.21-3.el8, but none of the providers can be installed
    - package deltarpm-3.6-3.el7.x86_64 requires librpm.so.3()(64bit), but none of the providers can be installed
    - package deltarpm-3.6-3.el7.x86_64 requires librpmio.so.3()(64bit), but none of the providers can be installed
    - conflicting requests
    - problem with installed package deltarpm-3.6-3.el7.x86_64

    Problem 3: package python3-dnf-4.7.0-4.el8.noarch requires dnf-data = 4.7.0-4.el8, but none of the providers can be installed
    - package dnf-4.7.0-4.el8.noarch requires python3-dnf = 4.7.0-4.el8, but none of the providers can be installed
    - cannot install both dnf-data-4.7.0-4.el8.noarch and dnf-data-4.0.9.2-2.el7_9.noarch
    - package yum-4.7.0-4.el8.noarch requires dnf = 4.7.0-4.el8, but none of the providers can be installed
    - package python2-dnf-4.0.9.2-2.el7_9.noarch requires dnf-data = 4.0.9.2-2.el7_9, but none of the providers can be installed
    - conflicting requests
    - problem with installed package python2-dnf-4.0.9.2-2.el7_9.noarch
    (try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages)

    Reply
    • @Sai,

      Does the following command is successful? I suggest you re-run the following command and see if there are any package conflicts, if yes remove those conflicts and run the command again.

      # dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
      
      Reply
  6. # dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
    Last metadata expiration check: 0:34:40 ago on Sun 14 Nov 2021 12:48:00 PM IST.
    Error:
    Problem: The operation would result in removing the following protected packages: kernel-plus

    Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.