Upgrade CentOS 7 to 8 – Most Comprehensive Guide

Share on Social Media

In this article, you will learn how to upgrade CentOS 7 to 8, including application software, that are already installed on your Linux operating system. #centlinux #linux

How one can Upgrade CentOS 7 to 8?

CentOS 8 has been released and most of the organizations looking forward to upgrade their existing installations of Linux servers.

Here, you will perform a complete upgrade of your operating system from CentOS 7 to 8 along with already installed applications (Apache web server) and databases (MySQL server).

There are many alternate ways to upgrade CentOS 7 to 8. The most popular and relatively easy method is to fresh install and configure CentOS 8 machine in parallel with our existing CentOS 7 machine and then migrate the applications and databases to the new upgraded machine each at a time.

But, we are executing an in-place upgrade of an existing CentOS 7 server with all installed applications and databases to the latest versions provided by CentOS 8 Linux operating system.

Since you are required to upgrade CentOS 7 to 8, therefore, it is recommended that you should also upgrade yourself and your technical resources as well.

For this purpose, we highly recommend that, you should read Red Hat RHCSA 8 Cert Guide: EX200 (Certification Guide) (PAID LINK) by Pearson IT Certification or it is even better if you can attend an online Linux training like Linux Command Line Masterclass with RHCSA & RHCE – 12 hours!show?id=oLRJ54lcVEg&bids=1060093

Environment Specification

We are using a virtual machine with following specifications, You can provision a same Linux server by following our tutorial on how to install LAMP Stack on CentOS 7.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 20 GB
  • Operating System – CentOS 7.7
  • Hostname – centos-7-server.centlinux.com
  • IP Address – 192.168.116.215 /24

Gather Linux System Information

Connect with centos-7-server.centlinux.com as root user by using a ssh client.

Check the current version of your Linux Kernel.

# uname -r
3.10.0-1062.7.1.el7.x86_64

Check the current version of your Apache web server.

# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Aug  8 2019 11:41:18

Check the current version of your PHP programming language.

# php -v
PHP 5.4.16 (cli) (built: Nov  1 2019 16:04:20)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

Check the current version of your MySQL database server.

# mysql -V
mysql  Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1

Open URL http://centos-7-server.centlinux.com in a web browser. You may need to create a phpinfo page just as we did in our another guide about how to install Multiple PHP versions on Linux.

PHPInfo 5.4
PHPInfo 5.4

Install EPEL Yum Repository

You are required some software packages that are not available in standard yum repositories therefore you have to install EPEL (Extra Packages for Enterprise Linux) yum repository before upgrade CentOS 7 to 8 operating system.

Install epel-release package to enable EPEL yum repository on your Linux operating system.

# yum install -y epel-release.noarch

Build cache for EPEL yum repository.

# yum makecache fast

EPEL yum repository for CentOS 7 has been installed.

Install Required Packages on CentOS 7

You need rpmconf and yum-utils to upgrade CentOS 7 to 8. Therefore, install these software packages by using yum command.

# yum install -y yum-utils rpmconf

Remove Duplicate/Unused Packages and Configurations

Locate and remove conflicting configuration files (.rpmnew, .rpmsave and .rpmorigfiles) by using rpmconf command. These files are created by Linux Package Manager during installation of a new version of an already installed software package.

# rpmconf -a
Configuration file `/etc/nsswitch.conf'
-rw-r--r--. 1 root root 1746 Dec 22  2018 /etc/nsswitch.conf
-rw-r--r--. 1 root root 1938 Aug  7 04:00 /etc/nsswitch.conf.rpmnew
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      M     : merge configuration files
      Z     : background this process to examine the situation
      S     : skip this file
 The default action is to keep your current version.
*** aliases (Y/I/N/O/D/Z/S) [default=N] ?
Your choice:

List down the packages that are not required by any other installed software.

# package-cleanup --leaves
Loaded plugins: fastestmirror
bind-libs-lite-9.11.4-9.P2.el7.x86_64
libsysfs-2.1.0-16.el7.x86_64

List down older or duplicate software packages that are not available in active yum repositories.

# package-cleanup --orphans
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ges.net.pk
 * epel: my.fedora.ipserverone.com
 * extras: mirrors.ges.net.pk
 * updates: repo.isra.edu.pk
kernel-3.10.0-957.el7.x86_64

Uninstall all the software packages that are listed by the above package-cleanup commands.

# yum remove -y 
> bind-libs-lite-9.11.4-9.P2.el7.x86_64 
> libsysfs-2.1.0-16.el7.x86_64 
> kernel-3.10.0-957.el7.x86_64

Upgrade Package Manager from YUM to DNF

In CentOS 8, the default Linux package manager, yum has been replaced by the dnf (Dandified Yum).

Therefore, you have to switch to the dnf package manager before starting process to upgrade CentOS 7 to 8.

Install dnf package manager by using yum command.

# yum install -y dnf

Yum is not required anymore, therefore you must remove it by executing dnf command.

# dnf remove -y yum yum-metadata-parser

Remove any left behind yum configurations.

# rm -Rf /etc/yum

Rebuild cache for yum repositories.

# dnf makecache
Extra Packages for Enterprise Linux 7 - x86_64   54 kB/s |  16 MB     05:08
CentOS-7 - Base                                 991 kB/s |  10 MB     00:10
CentOS-7 - Updates                              1.2 MB/s | 7.0 MB     00:05
CentOS-7 - Extras                               1.5 MB/s | 251 kB     00:00
Metadata cache created.

Upgrade CentOS 7 Packages to Latest Stable versions

Your Linux server is now ready to upgrade to CentOS 8.

Execute the following command at Linux Bash to update software packages to latest versions as provided by CentOS 7 yum repositories.

# dnf upgrade -y

Upgrade Yum Repositories from CentOS 7 to 8

To upgrade your yum repositories, you have to upgrade centos-release package from CentOS 7 to 8.

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

Upgrade EPEL yum repository from EL 7 to EL 8.

# dnf upgrade -y epel-release

Build cache for newly installed yum repositories.

# dnf makecache
Extra Packages for Enterprise Linux 8 - x86_64   30 kB/s | 5.2 MB     02:57
CentOS-8 - Base                                 0.0  B/s |   0  B     00:00
CentOS-8 - AppStream                            0.0  B/s |   0  B     00:00
CentOS-8 - Extras                               0.0  B/s |   0  B     00:00
Metadata cache created.

All of our yum repositories has been upgraded from CentOS 7 to CentOS 8.

Upgrade CentOS 7 to 8

Remove all installed kernels by executing following rpm command.

# rpm -e `rpm -q kernel`

If the above command provides any conflicting package, then you must to remove that package before uninstalling the Linux Kernels. 

We have only one conflicting package i.e. sysvinit-tools, so we are removing it by using rpm command.

# rpm -e --nodeps sysvinit-tools

Please ensure that, you have removed all the conflicting software packages before moving forward. You have to repeat the rpm -e ‘rpm -q kernel’ command again after removing the conflicting packages.

Upgrade Linux operating system by executing following command at Linux Bash.

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

After successful execution of previous command, install the new CentOS 8 kernel core. You can also read our previous article, if you want to upgrade to latest Linux kernel.

# dnf install -y kernel-core

Install Minimal and Core package groups on the server.

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

Reboot your operating system to load new Linux Kernel.

# systemctl reboot

Verify Software Versions after Upgrade

After reboot, check version of installed Linux Kernel.

# uname -r
4.18.0-147.3.1.el8_1.x86_64

Check version of installed Apache web server.

# httpd -v
Server version: Apache/2.4.37 (centos)
Server built:   Dec 23 2019 20:45:34

Check version of installed PHP programming language.

# php -v
PHP 7.2.11 (cli) (built: Oct  9 2018 15:09:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Check version of installed MySQL database server.

# mysql -V
mysql  Ver 15.1 Distrib 10.3.17-MariaDB, for Linux (x86_64) using readline 5.1

Open URL http://centos-7-server.centlinux.com in a web browser.

PHPInfo 7.2
PHPInfo 7.2

You have successfully upgrade CentOS 7 to 8, along with all the installed databases and applications.

Final Thoughts

Upgrading from CentOS 7 to CentOS 8 is a crucial step for keeping your system up-to-date with the latest features and security enhancements. This process involves careful planning, including backing up your data, checking the compatibility of applications, and following a systematic approach to ensure a smooth transition. By following this guide, you can successfully upgrade your system and take advantage of the improvements and advancements in CentOS 8. Remember, thorough preparation can help you avoid common pitfalls and ensure a seamless upgrade experience.

If you need professional assistance with your CentOS upgrade, feel free to check out my services on Fiverr: Linux System Administrator

44 thoughts on “Upgrade CentOS 7 to 8 – Most Comprehensive Guide”

  1. This works well, I appreciate the work that went into it. Well detailed documentation, and very easy to follow.

    I ran into an issue, because I had a great deal of software installed. I am putting my notes here, so others can get around the problem. It took some digging, and some trail and error.

    You may run into issues with gdbm and gdbm-lib getting upgraded.

    When you execute:

    [root@centos-7-server ~]# dnf -y –releasever=8 –allowerasing –setopt=deltarpm=false distro-sync

    You may get a cryptic error akin to:

    Error: transaction check vs depsolve:
    (gcc >= 8 with gcc < 9) is needed by annobin-8.78-1.el8.x86_64
    rpmlib(RichDependencies) <= 4.12.0-1 is needed by annobin-8.78-1.el8.x86_64
    (annobin if gcc) is needed by redhat-rpm-config-120-1.el8.noarch
    rpmlib(RichDependencies) <= 4.12.0-1 is needed by redhat-rpm-config-120-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'.

    What you need to do is:

    dnf install gdbm gdbm-libs –best –allowerasing

    You will get a list of package conflicts.

    Remove the indicated RHEL7 packages, and then issue again:

    dnf install gdbm gdbm-libs –best –allowerasing

    Then, execute the upgrade again:

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

    The upgrade should go to completion.

    Just so you know, you may have to install some third party software.

  2. I get as far as removing the installed kernels, and then hit problems:

    # rpm -e `rpm -q kernel`
    error: Failed dependencies:
    kernel >= 3.10.0-384.el7 is needed by (installed) hypervvssd-0-0.34.20180415git.el7.x86_64
    kernel >= 3.10.0-384.el7 is needed by (installed) hypervfcopyd-0-0.34.20180415git.el7.x86_64
    kernel >= 3.10.0-384.el7 is needed by (installed) hypervkvpd-0-0.34.20180415git.el7.x86_64
    kernel >= 2.6.32 is needed by (installed) lldpad-1.0.1-5.git036e314.el7.x86_64
    kernel >= 3.10.0-1086.el7 is needed by (installed) kmod-kvdo-6.1.3.7-5.el7.x86_64
    kernel(PDE_DATA) = 0x44f0d59d is needed by (installed) kmod-kvdo-6.1.3.7-5.el7.x86_64
    kernel(___ratelimit) = 0x155f4108 is needed by (installed) kmod-kvdo-6.1.3.7-5.el7.x86_64
    kernel(__bitmap_weight) = 0x4cbbd171 is needed by (installed) kmod-kvdo-6.1.3.7-5.el7.x86_64 etc.

    Trying to continue on the basis that the installed kernel is needed, I get:

    # dnf -y –releasever=8 –allowerasing –setopt=deltarpm=false distro-sync
    Last metadata expiration check: 0:01:39 ago on Tue 28 Apr 2020 15:52:19 BST.
    Error:
    Problem: The operation would result in removing the following protected packages: kernel

    Any ideas? This is on a test system, so not urgent.

  3. Hallo,

    it is not possible to copy the command under "Start system upgrade by using following command.", because it does not fit in the box on the website.

  4. Hi Ahmer, I followed these steps by now my grub does does not find the right image to boot. How should edit the entries to accommodate this new build out? Many thanks!

  5. Thanks for your instructions.
    For a fresh Amazon Lightsail CentOS 7 image, this step failed for me:

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

    It said there were conflicts with an existing package, python36-rpmconf-1.0.22-1.el7.noarch, so I removed that with

    dnf remove python36-rpmconf-1.0.22-1.el7.noarch

    It continued OK from there, except for the step with

    dnf -y groupupdate "Core" "Minimal Install"

    That said installing yum-4.2.7-7.el8_1.noarch failed, but I guess since dnf is installed, it's not a big deal.

  6. I've got the same problem – only with different "failed dependencies".
    You mean – in the case above – the packages hypervvssd-0-0.34.20180415git.el7.x86_64, hypervfcopyd-0-0.34.20180415git.el7.x86_64, …. should be removed?

    Kind regards

  7. Not all Linux servers are same, in fact each server has its own set of software packages.

    Therefore, do not consider these failed dependencies as issues.

    If you have observed a failed dependency, resolve it by using the advice in the above article.

  8. Hi, I got to the part where you execute "dnf -y –releasever=8 –allowerasing –setopt=deltarpm=false distro-sync" and it failed with the error "Problem: The operation would result in removing the following protected packages: kernel".

    Heeelllppppppp

    Thanks in anticipation 🙂

  9. I am also running into this problem.

    In my case I am getting:
    [root@system admin]# rpm -e `rpm -q kernel`
    error: Failed dependencies:
    kernel >= 2.6.32 is needed by (installed) lldpad-1.0.1-5.git036e314.el7.x86_64
    kernel >= 2.6.32 is needed by (installed) lldpad-1.0.1-5.git036e314.el7.x86_64
    [root@system admin]# dnf remove -y lldpad-1.0.1-5.git036e314.el7.x86_64
    Error:
    Problem: The operation would result in removing the following protected packages: kernel

    Seems to be a catch-22. Not sure how to force remove the kernel in this situation.

    Thanks.

  10. 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

    Kindly help on this error. I tried removing dnf from /etc/dnf/protected.d/ and /etc/yum/protected.d/. But no luck

  11. Really nice guide, but …

    Trying to upgrade 7.8 to latest, but requiring to access the repos via proxy. Had yum working (proxy=… in /etc/yum.conf, I think).
    However, after removing yum, dnf makecache does not do anything:
    # dnf makecache
    Extra Packages for Enterprise Linux 7 – x86_64 0.0 B/s | 0 B 00:00
    CentOS-7 – Base 0.0 B/s | 0 B 00:00
    CentOS-7 – Updates 0.0 B/s | 0 B 00:00
    CentOS-7 – Extras 0.0 B/s | 0 B 00:00
    Failed to synchronize cache for repo 'extras', ignoring this repo.
    Metadata cache created.

    http_proxy (et al) are correctly set in the env. Added "proxy=http://my-proxy:8080" to /etc/dnf/dnf.conf, but still no better metadata cache.

    This leads to the following upgrade:
    # dnf upgrade -y
    CentOS-7 – Extras 0.0 B/s | 0 B 00:00
    Failed to synchronize cache for repo 'extras', ignoring this repo.
    Last metadata expiration check: 0:01:50 ago on Thu 22 Oct 2020 12:22:29 PM CEST.
    Dependencies resolved.
    Nothing to do.
    Complete!

    Not having yum anymore and dnf not working leaves the system in a bad shape :-

  12. Forget my last comment … I misinterpreted the 'Nothing to do' as an error of the upgrade while it was just telling me that my Centos7 was up-to-date. Reading again and just continuing worked well (after adding the proxy to /etc/dnf/dnf.conf).

  13. [root@centos8-testing ~]# dnf –releasever=8 –allowerasing –setopt=deltarpm=false distro-sync
    warning: /var/cache/dnf/epel-6519ee669354a484/packages/rpmconf-1.0.21-1.el8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 2f86d6a1: NOKEY
    Extra Packages for Enterprise Linux 8 – x86_64 0.0 B/s | 0 B 00:00
    Importing GPG key 0x2F86D6A1:
    Userid : "Fedora EPEL (8) "
    Fingerprint: 94E2 79EB 8D8F 25B2 1810 ADF1 21EA 45AB 2F86 D6A1
    From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
    Is this ok [y/N]: y
    Key imported successfully
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    The downloaded packages were saved in cache until the next successful transaction.
    You can remove cached packages by executing 'dnf clean packages'.
    Error: Transaction check error:
    file /usr/sbin/pidof from install of procps-ng-3.3.15-1.el8.x86_64 conflicts with file from package sysvinit-tools-2.88-14.dsf.el7.x86_64
    file /usr/bin/last from install of util-linux-2.32.1-22.el8.x86_64 conflicts with file from package sysvinit-tools-2.88-14.dsf.el7.x86_64
    file /usr/bin/mesg from install of util-linux-2.32.1-22.el8.x86_64 conflicts with file from package sysvinit-tools-2.88-14.dsf.el7.x86_64
    file /usr/bin/wall from install of util-linux-2.32.1-22.el8.x86_64 conflicts with file from package sysvinit-tools-2.88-14.dsf.el7.x86_64
    file /usr/share/man/man1/last.1.gz from install of util-linux-2.32.1-22.el8.x86_64 conflicts with file from package sysvinit-tools-2.88-14.dsf.el7.x86_64
    file /usr/share/man/man1/mesg.1.gz from install of util-linux-2.32.1-22.el8.x86_64 conflicts with file from package sysvinit-tools-2.88-14.dsf.el7.x86_64
    file /usr/share/man/man1/wall.1.gz from install of util-linux-2.32.1-22.el8.x86_64 conflicts with file from package sysvinit-tools-2.88-14.dsf.el7.x86_64
    file /usr/lib/python3.6/site-packages/rpmconf/__pycache__/__init__.cpython-36.opt-1.pyc from install of python3-rpmconf-1.0.21-1.el8.noarch conflicts with file from package python36-rpmconf-1.0.22-1.el7.noarch
    file /usr/lib/python3.6/site-packages/rpmconf/__pycache__/__init__.cpython-36.pyc from install of python3-rpmconf-1.0.21-1.el8.noarch conflicts with file from package python36-rpmconf-1.0.22-1.el7.noarch
    file /usr/lib/python3.6/site-packages/rpmconf/__pycache__/rpmconf.cpython-36.opt-1.pyc from install of python3-rpmconf-1.0.21-1.el8.noarch conflicts with file from package python36-rpmconf-1.0.22-1.el7.noarch
    file /usr/lib/python3.6/site-packages/rpmconf/__pycache__/rpmconf.cpython-36.pyc from install of python3-rpmconf-1.0.21-1.el8.noarch conflicts with file from package python36-rpmconf-1.0.22-1.el7.noarch
    file /usr/share/man/man3/rpmconf.3.gz from install of python3-rpmconf-1.0.21-1.el8.noarch conflicts with file from package python36-rpmconf-1.0.22-1.el7.noarch

    Error Summary
    ————-

    Observing these errors at the moment. Any solution on this !!

  14. I ended up in a sistuation where the removal would result in removal of dnf. So it the upgarde was not possible.
    I used a fresh minimal Centos 7 in order to be sure no extra none Centos 7 packages were installed.

  15. The filenames listed in the step "Upgrading Yum Repositories from CentOS 7 to CentOS 8:" no longer exist; changing the command to their newer versions causes "not installed, cannot upgrade" messages. Do you have a solution? Thanks.

  16. Hi y have 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) <= 4.12.0-1 is needed by mariadb-connector-c-3.1.11-2.el8_3.x86_64

    Any Ideas?

  17. with the above I am getting a huge list, I am not sure weather I can remove all.

    Please see the actual error I am getting. may be that would help you to give right way forward with the conflicts.

    Error: transaction check vs depsolve:
    (gcc >= 8 with gcc < 9) is needed by annobin-9.72-1.el8_5.2.x86_64
    rpmlib(RichDependencies) <= 4.12.0-1 is needed by annobin-9.72-1.el8_5.2.x86_64
    (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

  18. Thank you Ahmer, I have tried with rpm –rebuilddb as system suggested, but it got failed.

    I was move forward with the below command and completed the upgrade.
    dnf -y –releasever=8 –allowerasing –setopt=deltarpm=false distro-sync –disablerepo=appstream

Leave a Comment