How to Upgrade CentOS 7 to CentOS 8

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Introduction

In this tutorial guide You will learn how to upgrade your Linux server from CentOS 7 to CentOS 8.

Just follow these steps:

Install the EPEL Repository

You need to install the EPL repository with the following command:

[root@unixcop ~]# yum install epel-release -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirror.ndchost.com
 * epel: mirror.prgmr.com
 * extras: mirrors.raystedman.org
 * updates: mirror.sjc02.svwh.net
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be updated
---> Package epel-release.noarch 0:7-13 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package                                  Arch                               Version                           Repository                        Size
======================================================================================================================================================
Updating:
 epel-release                             noarch                             7-13                              epel                              15 k

Transaction Summary
======================================================================================================================================================
Upgrade  1 Package

Total download size: 15 k
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/epel/packages/epel-release-7-13.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for epel-release-7-13.noarch.rpm is not installed
epel-release-7-13.noarch.rpm                                                                                                   |  15 kB  00:00:00     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
 Userid     : "Fedora EPEL (7) <[email protected]>"
 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 Package    : epel-release-7-11.noarch (@extras)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : epel-release-7-13.noarch                                                                                                           1/2 
  Cleanup    : epel-release-7-11.noarch                                                                                                           2/2 
  Verifying  : epel-release-7-13.noarch                                                                                                           1/2 
  Verifying  : epel-release-7-11.noarch                                                                                                           2/2 

Updated:
  epel-release.noarch 0:7-13                                                                                                                          

Complete!
[root@unixcop ~]#

Install yum-utils Tools

So Install yum-utils with command:

[root@unixcop ~]# yum install yum-utils -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.san.fastserv.com
 * epel: mirror.sfo12.us.leaseweb.net
 * extras: mirrors.raystedman.org
 * updates: mirror.sjc02.svwh.net
Resolving Dependencies
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be installed
--> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-54.el7_8.noarch
--> Processing Dependency: libxml2-python for package: yum-utils-1.1.31-54.el7_8.noarch
--> Running transaction check
---> Package libxml2-python.x86_64 0:2.9.1-6.el7.5 will be installed
---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed
--> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch
--> Running transaction check
---> Package python-chardet.noarch 0:2.2.1-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package                                 Arch                            Version                                  Repository                     Size
======================================================================================================================================================
Installing:
 yum-utils                               noarch                          1.1.31-54.el7_8                          base                          122 k
Installing for dependencies:
 libxml2-python                          x86_64                          2.9.1-6.el7.5                            base                          247 k
 python-chardet                          noarch                          2.2.1-3.el7                              base                          227 k
 python-kitchen                          noarch                          1.1.1-5.el7                              base                          267 k

Transaction Summary
======================================================================================================================================================
Install  1 Package (+3 Dependent packages)

Total download size: 863 k
Installed size: 4.3 M
Downloading packages:
(1/4): python-chardet-2.2.1-3.el7.noarch.rpm                                                                                   | 227 kB  00:00:00     
(2/4): libxml2-python-2.9.1-6.el7.5.x86_64.rpm                                                                                 | 247 kB  00:00:00     
(3/4): yum-utils-1.1.31-54.el7_8.noarch.rpm                                                                                    | 122 kB  00:00:00     
(4/4): python-kitchen-1.1.1-5.el7.noarch.rpm                                                                                   | 267 kB  00:00:00     
------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                 1.1 MB/s | 863 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python-chardet-2.2.1-3.el7.noarch                                                                                                  1/4 
  Installing : python-kitchen-1.1.1-5.el7.noarch                                                                                                  2/4 
  Installing : libxml2-python-2.9.1-6.el7.5.x86_64                                                                                                3/4 
  Installing : yum-utils-1.1.31-54.el7_8.noarch                                                                                                   4/4 
  Verifying  : libxml2-python-2.9.1-6.el7.5.x86_64                                                                                                1/4 
  Verifying  : python-kitchen-1.1.1-5.el7.noarch                                                                                                  2/4 
  Verifying  : yum-utils-1.1.31-54.el7_8.noarch                                                                                                   3/4 
  Verifying  : python-chardet-2.2.1-3.el7.noarch                                                                                                  4/4 

Installed:
  yum-utils.noarch 0:1.1.31-54.el7_8                                                                                                                  

Dependency Installed:
  libxml2-python.x86_64 0:2.9.1-6.el7.5              python-chardet.noarch 0:2.2.1-3.el7              python-kitchen.noarch 0:1.1.1-5.el7             

Complete!
[root@unixcop ~]#

You now need to resolve the RPM packages with commands below:

First install rpmconf

# yum install rpmconf

Then resolve RPM packs with:

[root@unixcop ~]# rpmconf -a
Configuration file '/etc/nsswitch.conf'
-rw-r--r--. 1 root root 1938 Apr 28 09:31 /etc/nsswitch.conf.rpmnew
-rw-r--r--. 1 root root 1746 Aug 20 07:14 /etc/nsswitch.conf

 ==> 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/M/Z/S) [default=N] ? 
Your choice: N
[root@unixcop ~]#

So The default action which N is to keep package maintainer’s version.

Next, perform a clean up of all the packages you don’t need with the following commands:

[root@unixcop ~]# package-cleanup --leaves
Loaded plugins: fastestmirror
bind-libs-lite-9.11.4-26.P2.el7_9.5.x86_64
libsysfs-2.1.0-16.el7.x86_64
[root@unixcop ~]# 
[root@unixcop ~]# package-cleanup --orphans
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirror.ndchost.com
 * epel: mirror.sfo12.us.leaseweb.net
 * extras: mirrors.raystedman.org
 * updates: mirror.sjc02.svwh.net
kernel-3.10.0-957.el7.x86_64
[root@unixcop ~]#

Install the dnf in CentOS 7

DNF is the default package manager in CentOS 8. Install it with command:

# yum install dnf

Now remove the yum package manager with commands below:

[root@unixcop ~]# dnf remove yum yum-metadata-parser -y
Dependencies resolved.
======================================================================================================================================================
 Package                                      Arch                       Version                                    Repository                   Size
======================================================================================================================================================
Removing:
 yum                                          noarch                     3.4.3-168.el7.centos                       @System                     5.6 M
 yum-metadata-parser                          x86_64                     1.1.4-10.el7                               @System                      57 k
Removing dependent packages:
 yum-plugin-fastestmirror                     noarch                     1.1.31-54.el7_8                            @System                      53 k
 yum-utils                                    noarch                     1.1.31-54.el7_8                            @System                     337 k

Transaction Summary
======================================================================================================================================================
Remove  4 Packages

Freed space: 6.0 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                              1/1 
  Erasing          : yum-utils-1.1.31-54.el7_8.noarch                                                                                             1/4 
  Erasing          : yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch                                                                              2/4 
  Erasing          : yum-3.4.3-168.el7.centos.noarch                                                                                              3/4 
  Erasing          : yum-metadata-parser-1.1.4-10.el7.x86_64                                                                                      4/4 
  Verifying        : yum-3.4.3-168.el7.centos.noarch                                                                                              1/4 
  Verifying        : yum-metadata-parser-1.1.4-10.el7.x86_64                                                                                      2/4 
  Verifying        : yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch                                                                              3/4 
  Verifying        : yum-utils-1.1.31-54.el7_8.noarch                                                                                             4/4 

Removed:
  yum-3.4.3-168.el7.centos.noarch           yum-metadata-parser-1.1.4-10.el7.x86_64          yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch         
  yum-utils-1.1.31-54.el7_8.noarch         

Complete!
[root@unixcop ~]#
# rm -Rf /etc/yum

Upgrade CentOS 7 to CentOS 8

Firstly, upgrade the dnf package manager with command:

# dnf upgrade

Then install CentOS 8 release package using dnf with command below:

[root@unixcop ~]# dnf install http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/{centos-linux-repos-8-2.el8.noarch.rpm,centos-gpg-keys-8-2.el8.noarch.rpm,centos-linux-release-8.4-1.2105.el8.noarch.rpm} -y
Last metadata expiration check: 0:03:39 ago on Tue 24 Aug 2021 07:24:11 AM EDT.
centos-linux-repos-8-2.el8.noarch.rpm                                                                                  72 kB/s |  20 kB     00:00    
centos-gpg-keys-8-2.el8.noarch.rpm                                                                                     68 kB/s |  12 kB     00:00    
centos-linux-release-8.4-1.2105.el8.noarch.rpm                                                                        266 kB/s |  22 kB     00:00    
Dependencies resolved.
======================================================================================================================================================
 Package                                   Arch                        Version                                Repository                         Size
======================================================================================================================================================
Installing:
 centos-linux-repos                        noarch                      8-2.el8                                @commandline                       20 k
 centos-gpg-keys                           noarch                      1:8-2.el8                              @commandline                       12 k
 centos-linux-release                      noarch                      8.4-1.2105.el8                         @commandline                       22 k
     replacing  centos-release.x86_64 7-9.2009.1.el7.centos

Transaction Summary
======================================================================================================================================================
Install  3 Packages

Total size: 53 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                              1/1 
  Installing       : centos-gpg-keys-1:8-2.el8.noarch                                                                                             1/4 
  Installing       : centos-linux-release-8.4-1.2105.el8.noarch                                                                                   2/4 
  Installing       : centos-linux-repos-8-2.el8.noarch                                                                                            3/4 
  Obsoleting       : centos-release-7-9.2009.1.el7.centos.x86_64                                                                                  4/4 
warning: file /etc/yum/vars/infra: remove failed: No such file or directory
warning: file /etc/yum/vars/contentdir: remove failed: No such file or directory

  Verifying        : centos-linux-repos-8-2.el8.noarch                                                                                            1/4 
  Verifying        : centos-gpg-keys-1:8-2.el8.noarch                                                                                             2/4 
  Verifying        : centos-linux-release-8.4-1.2105.el8.noarch                                                                                   3/4 
  Verifying        : centos-release-7-9.2009.1.el7.centos.x86_64                                                                                  4/4 

Installed:
  centos-linux-repos-8-2.el8.noarch              centos-gpg-keys-1:8-2.el8.noarch              centos-linux-release-8.4-1.2105.el8.noarch             

Complete!
[root@unixcop ~]#

Next, upgrade the EPEL repository as follows:

[root@unixcop ~]# dnf upgrade https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y
Extra Packages for Enterprise Linux 7 - x86_64                                                                         14 MB/s |  17 MB     00:01    
CentOS Linux 8 - BaseOS                                                                                               7.2 MB/s | 5.6 MB     00:00    
CentOS Linux 8 - AppStream                                                                                             39 MB/s | 8.8 MB     00:00    
CentOS Linux 8 - Extras                                                                                               141 kB/s |  10 kB     00:00    
epel-release-latest-8.noarch.rpm                                                                                       60 kB/s |  23 kB     00:00    
Dependencies resolved.
======================================================================================================================================================
 Package                               Arch                            Version                            Repository                             Size
======================================================================================================================================================
Upgrading:
 epel-release                          noarch                          8-11.el8                           @commandline                           23 k

Transaction Summary
======================================================================================================================================================
Upgrade  1 Package

Total size: 23 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                              1/1 
  Upgrading        : epel-release-8-11.el8.noarch                                                                                                 1/2 
  Cleanup          : epel-release-7-13.noarch                                                                                                     2/2 
  Verifying        : epel-release-8-11.el8.noarch                                                                                                 1/2 
  Verifying        : epel-release-7-13.noarch                                                                                                     2/2 

Upgraded:
  epel-release-8-11.el8.noarch                                                                                                                        

Complete!
[root@unixcop ~]#

Now, remove all the temporary files with the following command:

[root@unixcop ~]# dnf clean all
55 files removed
[root@unixcop ~]#

Remove the old CentOS 7 kernel core with command:

# rpm -e `rpm -q kernel`

Also you need to remove all conflicting packages with command below:

# rpm -e --nodeps sysvinit-tools

Launch the CentOS 8 system upgrade as shown below:

[root@unixcop ~]# dnf --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync -y
Extra Packages for Enterprise Linux 8 - x86_64                                                                        8.2 MB/s |  10 MB     00:01    
CentOS Linux 8 - BaseOS                                                                                               7.2 MB/s | 5.6 MB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64                                                                5.1 MB/s | 931 kB     00:00    
CentOS Linux 8 - AppStream                                                                                             38 MB/s | 8.8 MB     00:00    
CentOS Linux 8 - Extras                                                                                               166 kB/s |  10 kB     00:00    
Dependencies resolved.
.......
...

Install the New Kernel Core for CentOS 8

To install a new kernel for CentOS 8, use this command below:

# dnf install kernel-core -y

NOTE:

You may have some issues wit the command above that thers is a Problem: conflicting requests to the packages

So you can add this options to the command to solve this issue:

# dnf install kernel-core -y --allowerasing --skip-broken
  • The –allowerasing option to replace conflicting packages.
  • The –skip-broken option to skip uninstallable packages.

Install CentOS 8 minimal packages

You are now ready to install CentOS 8 minimal package, You can do this with running below command:

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

NOTE:

Also if you have the same problem above you can use this command to solve the issue:

# dnf groupupdate "Core" "Minimal Install" -y --allowerasing --skip-broken

So the CentOS 7 to CentOS 8 upgrade task has been completed!

Now you can check the version of CentOS with :

[root@unixcop ~]# cat /etc/redhat-release
CentOS Linux release 8.4.2105
[root@unixcop ~]#

Conclusion

So This article shows you how you can upgrade from CentOS 7 to CentOS 8.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
MQ-Jr
MQ-Jr
unixcop Admin

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook