Upgrade CentOS 7 to CentOS 8 inplace

I wanted to upgrade one of my servers from CentOS 7 to CentOS 8. The following are the steps I followed :

Check the kernel version

Before we start the upgrade process, let us see the kernel version.

# uname -a
Linux centostest 3.10.0-1127.el7.x86_64 #1 SMP Tue Mar 31 23:36:51 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Installing basic packages

Now let us begin with installing the basic packages.

yum install epel-release -y

EPEL provides a set of additional packages for CentOS, RHEL from the Fedora sources.

yum install yum-utils rpmconf

yum-utils is a collection of utility tools and programs for managing yum repositories, installing different packages such as debug packages, source packages.

rpmconf searches for .rpmnew, .rpmsave, and .rpmorigfiles and asks the user what to do with them.

The following cammand will check the configuration files of all packages and ask users for input.

rpmconf -a

Install dnf package manager

dnf is the replacement for yum in the newer version of the OS.

yum install dnf

Remove yum

Remove yum, the default package manager for CentOS 7, and yum configuration file to avoid any conflict with dnf. Since for CentOS 8 dnf is the primary package manager.

dnf -y remove yum yum-metadata-parser

rm -Rf /etc/yum

Getting CentOS 8 release packages

We are all set to upgrade from CentOS 7 to CentOS 8, but we need to upgrade the system before that.

dnf upgrade

This will update packages to their latest versions that are both available and resolvable.
I have installed CentOS 8 release packages and also for EPEL.

dnf install http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/{centos-linux-repos-8-2.el8.noarch.rpm,centos-linux-release-8.4-1.2105.el8.noarch.rpm,centos-gpg-keys-8-2.el8.noarch.rpm}
dnf -y upgrade https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf clean all

Removed the old kernel core of CentOS 7 and conflicting packages along with it.

rpm -e `rpm -q kernel`
rpm -e --nodeps sysvinit-tools

CentOS 8 system upgrade

The following packages, dracut-network and rpmconf, conflicts upgrade process, therefore removed them.

dnf remove dracut-network rpmconf

With the following dnf command, we ask to download all the non deltarpms for CentOS 8.

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

Installing a new kernel

To get the new kernel for CentOS 8, run the following command.

dnf -y install kernel-core

The final step would be to install CenOS 8 minimal packages.

dnf -y groupupdate "Core" "Minimal Install"

After all done:

# cat /etc/os-release
NAME="CentOS Linux"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"

Now run reboot to complete the upgrade.

Log back to the server, check the kernel version, and TaDa! We have CentOS 8 running on the system.

# uname -a
Linux centostest 4.18.0-305.10.2.el8_4.x86_64 #1 SMP Tue Jul 20 17:25:16 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Happy upgrading :)

Show Comments