Search The Hostwinds Guides Knowledge Base

Upgrading from CentOS 7 to 8

Share This Article [TheChamp-Sharing]

As new versions of software are released, you may be looking to update your installation in order to receive all of the latest and greatest features the new version offers. The same can also apply to your server’s operating system.

Since a new version of the popular Linux-based operating system, CentOS, has been released, you may be wanting to look into upgrading your server to this new version.

In Hostwinds’ Cloud infrastructure, we do have a pre-made CentOS 8 image that you can use to easily reinstall a server to. However, that option reinstalls the entire operating system of the server, meaning that any data on the server would be lost.

As such, if you are wanting to upgrade from CentOS 7 to 8 without needing to backup and restore your data, the upgrade must be done manually. This guide will go over the process to get your CentOS 7 server directly upgraded to CentOS 8.

All the following steps you will need to perform from your server’s terminal, which you can access by connecting to your server via SSH. Once connected, follow the following sections in order to perform the upgrade.

It is highly recommended to take a snapshot of your VPS prior to attempting this upgrade, just in case you need a backup of your server that can be easily restored.

Cleaning Up CentOS 7

Before we can install CentOS 8, it is best to clean up your current system, so that there are no leftover, unneeded, or conflicting packages.

In order to do this, first make sure your system is up to date:

yum update -y

Next, make sure you have the epel-release repository installed:

yum install -y epel-release

Then install the yum-utils and rpmconf packages:

yum install -y yum-utils rpmconf

Now that rpmconf is installed, we will use it to resolve our rpm packages:

rpmconf -a

NOTE: if rpmconf detects that a new version of a configuration file is available from the pacakge maintainer and asks if you want to install it, select the default option of ‘N’ to keep your currently installed version.

And finally perform a cleanup for any uneeded or orphaned packages:

package-cleanup --leaves
package-cleanup --orphans

Replacing Packages

The next steps in switching to CentOS 8 are about replacing the essentially system packages and repositories with their CentOS 8 equivalents.

First, install a new rpm-based package manager called DNF:

yum install -y dnf

Secondly, remove the yum package manager:

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

Next run a system update with DNF:

dnf upgrade -y

Then install the CentOS 8 packages:

dnf install 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}

And upgrade the EPEL repository:

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

Finally, clean up all temporary files:

dnf clean all

Install the New Kernel and Release

The final steps in switching over to CentOS 8 are all about installing the new version of the Linux kernel, and the new CentOS 8 release itself.

First, remove the old kernel:

rpm -e `rpm -q kernel`

Then remove any conflicting packages:

rpm -e --nodeps sysvinit-tools

Next, start the CentOS 8 upgrade:

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

Then install the new kernel core:

dnf -y install kernel-core

And run the CentOS 8 Minimal install:

dnf -y groupupdate "Core" "Minimal Install"

Now your server has been successfully upgraded to CentOS 8, and you can verify your OS’s release version from the os-release and redhat-release files:

cat /etc/os-release
cat /etc/redhat-release

Related Articles