CentOS

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!

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

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

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

Alaric Bird

Alaric Bird is a seasoned Linux System Administrator with over a decade of experience in managing and optimizing Linux-based servers and infrastructure. Known for his expertise in server deployment, security hardening, and performance tuning, Alaric has a deep understanding of various Linux distributions, including Ubuntu, CentOS, and Red Hat Enterprise Linux. His skills extend to cloud platforms like AWS, where he effectively manages virtual private servers and services. Alaric is also proficient in scripting languages such as Bash and Python, which he uses to automate routine tasks, enhancing efficiency and reliability. With a strong commitment to continuous learning, he stays updated with the latest developments in open-source technologies and best practices. His problem-solving abilities, combined with excellent communication skills, make him a valuable asset to any IT team. In addition to his technical expertise, Alaric is passionate about mentoring junior administrators and fostering a collaborative environment.

View Comments

  • Thank you for the post. I upgraded my Plex Media Serve using this post and it worked perfectly fine.

  • All worked great, many thanks. But how in the world do you know this stuff? I've been a linux programmer for several years but the sys admin side of it still seems like total magic.

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

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

  • Hi, You should remove the conflicting packages as mentioned in the next step of the above article and then continue the rest of the steps.

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

  • 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!

Share
Published by
Alaric Bird

Recent Posts

Change Apache Document Root in Linux

Learn how to change Apache document root in Linux by following this step-by-step guide. Adjust…

2 weeks ago

How to Change Apache Port in Linux

Discover how to change Apache port in Linux easily. Follow our simple guide to modify…

2 weeks ago

How to Create Virtual Host in Apache Server

Learn how to create a virtual host in Apache Server with this comprehensive guide. Set…

3 weeks ago

10 Practical Tasks for RHCSA Exam with Solutions

Discover 10 practical tasks for the RHCSA exam with step-by-step solutions. Boost your Linux skills…

3 weeks ago

Ultimate Fail2ban Configuration Guide

Discover the ultimate Fail2ban configuration guide. Learn how to set up, customize, and optimize Fail2ban…

3 weeks ago

VPS Server: The Ultimate Guide to Virtual Private Servers

Explore the ultimate guide to VPS servers and learn everything about Virtual Private Servers, including…

4 weeks ago

This website uses cookies.