Upgrade CentOS Linux 8 to CentOS Stream 8

As you probably know (since you are visiting this page), the Linux distro known as CentOS is in for a big change. If you are unsure what this means I recommend reading these articles from Red Hat: What is CentOS Stream and CentOS Linux vs. CentOS Stream.

One rather important fact that I almost missed is that the current CentOS Linux 8 is reaching End Of Life on December 31st 2021.

If you are running CentOS Linux 8.x you can follow this guide and upgrade to CentOS Stream. I recently did this on my CentOS 8.5 server and everything went a lot smoother than I dared hope.

1. Backup, snapshop and planning

There is some important things you should consider before upgrading

  1. Backup: Make sure to backup your server first. Really you should already be doing this on a regular basis.
    I backed up my websites and a few essential scripts and configuration files to a remote server.
  2. Snapshot if possible: Since I am running a virtual server I also made sure to create a ‘snapshot’ of the server so I could roll back in case of disaster. I highly recommend doing this as it is without comparison the easiest way back if something breaks.
  3. Planning: The upgrade will switch the main CentOS repos to the Stream repos. This is a big deal and might break existing installed applications on your server, especially if you run a lot of custom built software and 3rd party repos.
    I have a few custom repos like RHEL EPEL and Remi’s Repos for PHP-8 installed on my server and they worked fine after the upgrade.

    I recommend that you write down all essential services running on your server and check their status and logs after the upgrade. Stuff like httpd, mysqld, nginx, sshd, etc.

If you are unsure what repos you are using on your server you can run this command and note down the current repos

sudo dnf repolist

2. Update your server

Make sure your server is up-to-date before proceeding. Just like backup this should be something you do on a regular basis, but let’s make sure anyway.

Log in to your server with ssh and run the following command

sudo dnf update

Install all updates and reboot the server to make sure that core updates are in effect.

sudo systemctl reboot

After reboot you should check the current OS version and make sure you are running on CentOS 8.x

sudo cat /etc/centos-release

3. Install CentOS Stream

Now it’s time to install the CentOS Stream 8 package containing what you need to upgrade/migrate

sudo dnf in centos-release-stream

It should look something like this

You are now ready to swap your current repos to the new Stream repos with the following command

sudo dnf swap centos-linux-repos centos-stream-repos

On my server the result looks like this

You are now ready to sync your installed packages with the updated packages available in the new Stream repos

sudo dnf distro-sync

This will probably take a while. Take notice of any Warnings or Errors, you want to address these to make sure your software and services still work.

When the sync and updates are completed and you are confident it went well you should reboot your server

sudo systemctl reboot

4. Finally

When your server has been rebooted your /etc/centos-release should reflect the changes

cat /etc/centos-release

You should also check logs like /var/log/messages, /var/log/httpd/* and other relevant logs for errors and warnings.

The relevant services you wrote down in the Planning step should be checked with systemctl

sudo systemctl status mysqld

So far I have not noticed any errors or instability after upgrading to CentOS Stream 8 and is pleasantly surprised by how easy it was. I hope you have a similar experience.

A final word: Don’t forget to remove your snapshot if you are confident everything is running as expected 😉 It’s very common to forget about snapshots and they take up quite a lot of space in the long run.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.