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.

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.

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

  1. Before yum install rpmconf do yum update, that will allow you to fix the issue with the error: import error: no module named _conf on step 3 ending.

    Reply
  2. Just FYI, I followed this blueprint to do an in-place upgrade from CentOS 8-Stream to 9-Stream. The biggest difference is that the CentOS 9-Stream mirrors are in a different place (you can find them on Mirror Manager). Otherwise, the above process worked pretty well and I had surprisingly few issues getting CentOS 9 up and running.

    Reply
  3. The command # dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync fails. It will try to remove the protected dnf package.

    Adding --setopt=protected_packages= is a really bad idea, because dnf is removed by itself.

    Then you have a system without dnf, yum, or rpm. Not recommended!

    Reply
  4. How to upgrade CentOS 7.9 to CentOS 8.5

    Type all the commands as root.

    # yum install epel-release -y
    # yum install yum-utils
    # yum install rpmconf
    # rpmconf -a
    

    Answer the questions using the default. Usuallly it is N, in httpd case it is Y.

    # package-cleanup --leaves
    # package-cleanup --orphans
    # yum install dnf
    # dnf -y remove yum yum-metadata-parser
    # rm -Rf /etc/yum
    # dnf upgrade
    # 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}
    # dnf -y upgrade https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm --best --allowerasing
    # dnf clean all
    # rpm -e `rpm -q kernel`
    # rpm -e --nodeps sysvinit-tools
    # dnf remove kexec-tools
    # dnf remove ivtv-firmware
    # dnf remove linux-firmware
    # cd /root
    # wget http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/linux-firmware-20210702-103.gitd79c2677.el8.noarch.rpm
    # wget https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/kernel-4.18.0-348.el8.x86_64.rpm
    # wget https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/kernel-modules-4.18.0-348.el8.x86_64.rpm
    # wget https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/kernel-core-4.18.0-348.el8.x86_64.rpm
    # rpm -iv linux-firmware-20210702-103.gitd79c2677.el8.noarch.rpm
    # rpm -iv kernel-modules-4.18.0-348.el8.x86_64.rpm
    # cp /lib/modules/4.18.0-348.el8.x86_64/symvers.gz /boot/
    # cd /boot 
    # mv symvers.gz symvers-4.18.0-348.el8.x86_64.gz
    # cd /root
    # rpm -iv --replacepkgs kernel-core-4.18.0-348.el8.x86_64.rpm
    # rpm -iv kernel-4.18.0-348.el8.x86_64.rpm
    # cat /etc/redhat-release
    # reboot
    

    Check during the boot process is everything ok. Should be OK.

    # dnf check-update
    # dnf update nameofthepackage --best --allowerasing
    

    ———————– this is not fixed by me yet ———————————————
    libssh2.x86_64 – this is not possible to be upgraded just because the problem is that it will not let the dnf package be removed

    Dependencies described here:
    http://rpm.pbone.net/info_idpl_75792859_distro_redhatel8_com_libssh2-1.9.0-5.el8.x86_64.rpm.html

    Seems this is a huge dependencies issue, just because all those four libraries are not enough

    # wget https://download-ib01.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/l/libssh2-1.9.0-5.el8.x86_64.rpm
    # rpm -Uivh libssh2-1.9.0-5.el8.x86_64.rpm
    error: Failed dependencies:
            libcrypto.so.1.1()(64bit) is needed by libssh2-1.9.0-5.el8.x86_64
            libcrypto.so.1.1(OPENSSL_1_1_0)(64bit) is needed by libssh2-1.9.0-5.el8.x86_64
            libcrypto.so.1.1(OPENSSL_1_1_1)(64bit) is needed by libssh2-1.9.0-5.el8.x86_64
            libssl.so.1.1()(64bit) is needed by libssh2-1.9.0-5.el8.x86_64
    

    If you will try to download this one for CentOS 8 that contains all four libraries.

    # wget https://vault.centos.org/8.1.1911/BaseOS/x86_64/os/Packages/openssl-libs-1.1.1c-2.el8_1.1.x86_64.rpm
    

    And then if you will try to install it with this command:

    # rpm -iv openssl-libs-1.1.1c-2.el8_1.1.x86_64.rpm
    

    It will show these dependencies for example below. So a big surprise.

    crypto-policies >= 20180730 is needed by openssl-libs-1:1.1.1c-2.el8_1.1.x86_64

    So

    # wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/kickstart/Packages/krb5-libs-1.18.2-14.el8.x86_64.rpm
    # rpm -iv krb5-libs-1.18.2-14.el8.x86_64.rpm
    
    warning: krb5-libs-1.18.2-14.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY
    error: Failed dependencies:
            /etc/crypto-policies/back-ends/krb5.config is needed by krb5-libs-1.18.2-14.el8.x86_64
            libc.so.6(GLIBC_2.25)(64bit) is needed by krb5-libs-1.18.2-14.el8.x86_64
            libc.so.6(GLIBC_2.27)(64bit) is needed by krb5-libs-1.18.2-14.el8.x86_64
            libcrypto.so.1.1()(64bit) is needed by krb5-libs-1.18.2-14.el8.x86_64
            libcrypto.so.1.1(OPENSSL_1_1_0)(64bit) is needed by krb5-libs-1.18.2-14.el8.x86_64
            libcrypto.so.1.1(OPENSSL_1_1_1b)(64bit) is needed by krb5-libs-1.18.2-14.el8.x86_64
            libssl.so.1.1()(64bit) is needed by krb5-libs-1.18.2-14.el8.x86_64
            libssl.so.1.1(OPENSSL_1_1_0)(64bit) is needed by krb5-libs-1.18.2-14.el8.x86_64
            openssl-libs >= 1:1.1.1c-4 is needed by krb5-libs-1.18.2-14.el8.x86_64
    

    Maybe it is possible to solve it by you know, checking which library has to be downloaded first and then downloading and installing them one by one in the correct order. Some day maybe will find out is it possible, but I am not sure.

    Reply
  5. Thereafter, launch the CentOS 8 system upgrade as shown.

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

    This will fail. So, instead of the above do the below without reboot:

    # dnf remove kexec-tools
    # dnf remove ivtv-firmware
    # dnf remove linux-firmware
    # cd /root
    # wget http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/linux-firmware-20210702-103.gitd79c2677.el8.noarch.rpm
    # wget https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/kernel-4.18.0-348.el8.x86_64.rpm
    # wget https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/kernel-modules-4.18.0-348.el8.x86_64.rpm
    # wget https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/kernel-core-4.18.0-348.el8.x86_64.rpm
    # rpm -iv linux-firmware-20210702-103.gitd79c2677.el8.noarch.rpm
    # rpm -iv kernel-modules-4.18.0-348.el8.x86_64.rpm
    # cp /lib/modules/4.18.0-348.el8.x86_64/symvers.gz /boot/
    # cd /boot 
    # mv symvers.gz symvers-4.18.0-348.el8.x86_64.gz
    # cd /root
    # rpm -iv --replacepkgs kernel-core-4.18.0-348.el8.x86_64.rpm
    # rpm -iv kernel-4.18.0-348.el8.x86_64.rpm
    # cat /etc/redhat-release
    # reboot
    

    Check during the boot process is everything ok. Should be.

    Reply
  6. Replace:
    # dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
    with:

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

    Reply
  7. Running operation verification
    Error: operation verification vs depsolve:
    (NetworkManager >= 1.20 or dhclient) is needed by dracut-network-049-201.git20220131.el8.x86_64
    rpmlib(RichDependencies) <= 4.12.0-1 is needed by dracut-network-049-201.git20220131.el8.x86_64
    To detect the problem, try running: 'rpm -Va –nofiles –nodigest'.
    You probably have a corrupted RPMDB, running 'rpm –rebuilddb' might fix the problem.
    The downloaded packages have been cached for the next transaction.
    You can clear packages from cache by removing 'dnf clean packages'.

    Reply
  8. Unfortunately, the vault.centos.org repo for CentOS 8 is out, too.

    I just skipped CentOS entirely and From CentOS 7 I upgraded directly to CentOS 8 Stream using

    dnf install --allowerasing http://mirrors.advancedhosters.com/centos/8-stream/BaseOS/x86_64/os/Packages/{centos-stream-repos-8-3.el8.noarch.rpm,centos-stream-release-8.6-1.el8.noarch.rpm,centos-gpg-keys-8-3.el8.noarch.rpm}

    along with a few adjustments.

    Reply
      • Confirm it works with vault repos or with stream repos.

        Did upgrade with both repos.

        In some cases you can’t remove kernels from working OS, so you should boot into recovery mode and do it manually.

        1. Download kernel, kernel-core and kernel-modules, linux-firmware.

        wget https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/kernel-4.18.0-348.el8.x86_64.rpm
        wget https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/kernel-modules-4.18.0-348.el8.x86_64.rpm
        wget https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/kernel-core-4.18.0-348.el8.x86_64.rpm
        

        2. Boot in rescue mode and remove existing linux-firmware package and install downloaded package.

        dnf remove kexec-tools
        dnf remove ivtv-firmware
        dnf remove linux-firmware
        

        3. Then Install kernel packages by (rpm -iv kernel*).

        rpm -iv linux-firmware-20210702-103.gitd79c2677.el8.noarch.rpm
        rpm -iv kernel-modules-4.18.0-348.el8.x86_64.rpm
        /boot/symvers -> symlink /lib/moules/4.18…/symvers.gz
        rpm -iv --replacepkgs kernel-core-4.18.0-348.el8.x86_64.rpm
        rpm -e --nodeps sysvinit-tools
        rpm -q kernel-3.10.... (your kernels here)  and soft that depends on it
        

        5. Reboot.

        Reply
        • # rpm -iv linux-firmware-20210702-103.gitd79c2677.el8.noarch.rpm
          error: open of linux-firmware-20210702-103.gitd79c2677.el8.noarch.rpm failed: No such file or directory

          # rpm -iv kernel-modules-4.18.0-348.el8.x86_64.rpm
          error: Failed dependencies:
          kernel-uname-r = 4.18.0-348.el8.x86_64 is needed by kernel-modules-4.18.0-348.el8.x86_64

          # /boot/symvers -> symlink /lib/moules/4.18…/symvers.gz
          bash: /boot/symvers: No such file or directory

          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.