How to Upgrade CentOS 7 to CentOS 8

!Warning!

  1. "yum" will be uninstalled after this update, you will need to use dnf to update your VPS further.
  2. Run the commands listed below only after taking a backup of your data!

First, install the EPEL repository,

yum install epel-release -y

Sample output:

Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-11.noarch                                     1/1
  Verifying  : epel-release-7-11.noarch                                     1/1

Installed:
  epel-release.noarch 0:7-11

Complete!

To install yum utils.

yum install yum-utils

Sample output:

Total download size: 862 k
Installed size: 4.3 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): python-chardet-2.2.1-3.el7.noarch.rpm               | 227 kB   00:00
(2/4): libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm           | 247 kB   00:00
(3/4): python-kitchen-1.1.1-5.el7.noarch.rpm               | 267 kB   00:00
(4/4): yum-utils-1.1.31-52.el7.noarch.rpm                  | 121 kB   00:00
--------------------------------------------------------------------------------
Total                                              5.4 MB/s | 862 kB  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_2.3.x86_64                        3/4
  Installing : yum-utils-1.1.31-52.el7.noarch                               4/4
  Verifying  : python-kitchen-1.1.1-5.el7.noarch                            1/4
  Verifying  : yum-utils-1.1.31-52.el7.noarch                               2/4
  Verifying  : libxml2-python-2.9.1-6.el7_2.3.x86_64                        3/4
  Verifying  : python-chardet-2.2.1-3.el7.noarch                            4/4

Installed:
  yum-utils.noarch 0:1.1.31-52.el7

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

Complete!

To configure RPM packages.

yum install rpmconf
rpmconf -a

Sample output:

Total download size: 21 k
Installed size: 45 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/epel/packages/rpmconf-0.3.4-1.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for rpmconf-0.3.4-1.el7.noarch.rpm is not installed
rpmconf-0.3.4-1.el7.noarch.rpm                             |  21 kB   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
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : rpmconf-0.3.4-1.el7.noarch                                   1/1
  Verifying  : rpmconf-0.3.4-1.el7.noarch                                   1/1

Installed:
  rpmconf.noarch 0:0.3.4-1.el7

Complete!

After clean all packages which is not require.

package-cleanup --leaves

Sample output:

Loaded plugins: fastestmirror
libsysfs-2.1.0-16.el7.x86_64
package-cleanup --orphans

Sample output:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.23media.com
 * epel: mirror.de.leaseweb.net
 * extras: ftp.rz.uni-frankfurt.de
 * updates: mirror.fra10.de.leaseweb.net
GeoIP-1.5.0-13.el7.x86_64
NetworkManager-1.12.0-6.el7.x86_64
NetworkManager-libnm-1.12.0-6.el7.x86_64
NetworkManager-team-1.12.0-6.el7.x86_64
NetworkManager-tui-1.12.0-6.el7.x86_64
alsa-lib-1.1.6-2.el7.x86_64
audit-2.8.4-4.el7.x86_64
audit-libs-2.8.4-4.el7.x86_64
bash-4.2.46-31.el7.x86_64
bind-libs-lite-9.9.4-72.el7.x86_64
bind-license-9.9.4-72.el7.noarch
binutils-2.27-34.base.el7.x86_64
biosdevname-0.7.3-1.el7.x86_64
centos-release-7-6.1810.2.el7.centos.x86_64
coreutils-8.22-23.el7.x86_64
cronie-1.4.11-19.el7.x86_64
cronie-anacron-1.4.11-19.el7.x86_64
cryptsetup-libs-2.0.3-3.el7.x86_64
curl-7.29.0-51.el7.x86_64
dbus-1.10.24-12.el7.x86_64
dbus-libs-1.10.24-12.el7.x86_64
device-mapper-1.02.149-8.el7.x86_64
device-mapper-libs-1.02.149-8.el7.x86_64
dhclient-4.2.5-68.el7.centos.1.x86_64
dhcp-common-4.2.5-68.el7.centos.1.x86_64
dhcp-libs-4.2.5-68.el7.centos.1.x86_64
selinux-policy-targeted-3.13.1-229.el7.noarch
sg3_utils-1.37-17.el7.x86_64
sg3_utils-libs-1.37-17.el7.x86_64
shadow-utils-4.1.5.1-25.el7.x86_64
sudo-1.8.23-3.el7.x86_64
systemd-219-62.el7.x86_64
systemd-libs-219-62.el7.x86_64
systemd-sysv-219-62.el7.x86_64
teamd-1.27-5.el7.x86_64
tuned-2.10.0-6.el7.noarch
tzdata-2018e-3.el7.noarch
util-linux-2.23.2-59.el7.x86_64
vim-minimal-7.4.160-5.el7.x86_64
xfsprogs-4.5.0-18.el7.x86_64
yum-3.4.3-161.el7.centos.noarch
yum-plugin-fastestmirror-1.1.31-50.el7.noarch

To install dnf in CentOS 7.

yum install dnf

Sample output:

Installed:
  dnf.noarch 0:4.0.9.2-1.el7_6

Dependency Installed:
  deltarpm.x86_64 0:3.6-3.el7
  dnf-data.noarch 0:4.0.9.2-1.el7_6
  libcomps.x86_64 0:0.1.8-12.el7
  libdnf.x86_64 0:0.22.5-1.el7_6
  libmodulemd.x86_64 0:1.6.3-1.el7
  librepo.x86_64 0:1.8.1-7.el7
  libreport-filesystem.x86_64 0:2.1.11-43.el7.centos
  libsolv.x86_64 0:0.6.34-4.el7
  libyaml.x86_64 0:0.1.4-11.el7_0
  python-enum34.noarch 0:1.0.4-1.el7
  python2-dnf.noarch 0:4.0.9.2-1.el7_6
  python2-hawkey.x86_64 0:0.22.5-1.el7_6
  python2-libcomps.x86_64 0:0.1.8-12.el7
  python2-libdnf.x86_64 0:0.22.5-1.el7_6

Complete!

To remove yum package.

dnf -y remove yum yum-metadata-parser
rm -Rf /etc/yum

Sample output:

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-52.el7.noarch                         1/4
  Erasing          : yum-plugin-fastestmirror-1.1.31-50.el7.noarch          2/4
  Erasing          : yum-3.4.3-161.el7.centos.noarch                        3/4
  Erasing          : yum-metadata-parser-1.1.4-10.el7.x86_64                4/4
  Verifying        : yum-3.4.3-161.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-50.el7.noarch          3/4
  Verifying        : yum-utils-1.1.31-52.el7.noarch                         4/4

Removed:
  yum-3.4.3-161.el7.centos.noarch
  yum-metadata-parser-1.1.4-10.el7.x86_64
  yum-plugin-fastestmirror-1.1.31-50.el7.noarch
  yum-utils-1.1.31-52.el7.noarch

Complete!

To upgrade CentOS 7 to CentOS 8

To Upgrade dnf package. [This will take while to upgrade]

dnf upgrade

Sample output:

Installed:
  bind-export-libs-32:9.11.4-9.P2.el7.x86_64   geoipupdate-2.5.0-1.el7.x86_64
  kernel-3.10.0-1062.4.3.el7.x86_64

Complete!

To install CentOS 8 Package.

dnf -y upgrade http://mirror.bytemark.co.uk/centos/8/BaseOS/x86_64/os/Packages/centos-release-8.0-0.1905.0.9.el8.x86_64.rpm

Sample Output:

Extra Packages for Enterprise Linux 7 - x86_64   46 MB/s |  16 MB     00:00
centos-release-8.0-0.1905.0.9.el8.x86_64.rpm    300 kB/s |  26 kB     00:00
Dependencies resolved.
================================================================================
 Package            Arch       Version                   Repository        Size
================================================================================
Upgrading:
 centos-release     x86_64     8.0-0.1905.0.9.el8        @commandline      26 k

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

Total size: 26 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Upgrading        : centos-release-8.0-0.1905.0.9.el8.x86_64               1/2
  Cleanup          : centos-release-7-7.1908.0.el7.centos.x86_64            2/2
  Verifying        : centos-release-8.0-0.1905.0.9.el8.x86_64               1/2
  Verifying        : centos-release-7-7.1908.0.el7.centos.x86_64            2/2

Upgraded:
  centos-release-8.0-0.1905.0.9.el8.x86_64

Complete!

To upgrade the EPEL repository.

dnf -y upgrade https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Sample output:

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

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

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

Complete!

To remove temporary files.

dnf clean all

Sample output:

62 files removed

To remove CentOS 7 kernel Core.

rpm -e `rpm -q kernel`

To remove conflict packages incase.

rpm -e --nodeps sysvinit-tools

Launch CentOS 8 Syatem upgrade. [It will take while to upgrade]

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

Sample output:

Upgrading        : lzo-2.08-14.el8.x86_64                              90/676
  Upgrading        : pciutils-libs-3.5.6-4.el8.x86_64                    91/676
  Running scriptlet: pciutils-libs-3.5.6-4.el8.x86_64                    91/676
  Upgrading        : pcre-8.42-4.el8.x86_64                              92/676
  Running scriptlet: pcre-8.42-4.el8.x86_64                              92/676
semodule: relocation error: semodule: symbol semanage_module_info_get_version version LIBSEMANAGE_1.1 not defined in file libsemanage.so.1 with link time reference

  Upgrading        : grep-3.1-6.el8.x86_64                               93/676
  Running scriptlet: grep-3.1-6.el8.x86_64                               93/676
  Upgrading        : xz-5.2.4-3.el8.x86_64                               94/676
  Installing       : squashfs-tools-4.3-17.el8.x86_64                    95/676
  Upgrading        : libnetfilter_conntrack-1.0.6-5.el8.x86_64           96/676
  Running scriptlet: libnetfilter_conntrack-1.0.6-5.el8.x86_64           96/676
  Upgrading        : libteam-1.27-10.el8.x86_64                          97/676
  Running scriptlet: libteam-1.27-10.el8.x86_64                          97/676
  Upgrading        : groff-base-1.22.3-18.el8.x86_64                     98/676
  Upgrading        : acl-2.2.53-1.el8.x86_64                             99/676
  Upgrading        : vim-minimal-2:8.0.1763-10.el8.x86_64               100/676
  Installing       : libpsl-0.20.2-5.el8.x86_64                         101/676

  Complete!

To install Kernel core for CentOS 8.

dnf -y install kernel-core

Sample output:

Last metadata expiration check: 0:07:29 ago on Fri 15 Nov 2019 03:17:24 PM EST.
Package kernel-core-4.18.0-80.11.2.el8_0.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

To install minimal package for CentOS 8.

dnf -y groupupdate "Core" "Minimal Install"

Sample output:

Last metadata expiration check: 0:08:19 ago on Fri 15 Nov 2019 03:17:24 PM EST.
Dependencies resolved.
========================================================================================================
 Package                         Arch      Version                                   Repository    Size
========================================================================================================
Installing group/module packages:
 dnf-plugin-spacewalk            noarch    2.8.5-11.module_el8.0.0+180+337688dc      AppStream     24 k
 dnf-plugins-core                noarch    4.0.2.2-3.el8                             BaseOS        59 k
 prefixdevname                   x86_64    0.1.0-6.el8                               BaseOS       466 k
 rng-tools                       x86_64    6.6-2.el8                                 BaseOS        57 k
 sssd-common                     x86_64    2.0.0-43.el8_0.3                          BaseOS       1.4 M
 sssd-kcm                        x86_64    2.0.0-43.el8_0.3                          BaseOS       207 k
 yum                             noarch    4.0.9.2-5.el8                             BaseOS       173 k
Installing dependencies:
 python3-dnf-plugin-spacewalk    noarch    2.8.5-11.module_el8.0.0+180+337688dc      AppStream     30 k
 python3-hwdata                  noarch    2.3.6-3.el8                               AppStream     39 k
 python3-netifaces               x86_64    0.10.6-4.el8                              AppStream     25 k
 python3-newt                    x86_64    0.52.20-9.el8                             AppStream     63 k
 python3-pyOpenSSL               noarch    18.0.0-1.el8                              AppStream    103 k
 python3-rhn-client-tools        x86_64    2.8.16-13.module_el8.0.0+180+337688dc     AppStream    109 k
 python3-rhnlib                  noarch    2.8.6-8.module_el8.0.0+180+337688dc       AppStream     77 k

Reboot Your system.

 reboot

To check CentOS Version installed.

 cat /etc/redhat-release

Sample output:

 CentOS Linux release 8.1.1905 (core)