How to upgrade to CentOS Stream 9 from CentOS Stream 8

This article will show how to update to CentOS Stream 9 from CentOS Stream 8.

main menu
grub entries

If only official repositories are used it is fairly easy to upgrade to the new rolling based CentOS Stream 9 release, which follows the Red Hat Enterprise Linux 9. Using unofficial or users’ repositories CentOS Stream 8 may lead to unstable system or break user’s system following this tutorial. First, check out for CentOS Stream 9 compatibility issues the currently installed repositories if some specific or unofficial are used.
The following article uses a CentOS Stream 9 with only the official default repositories and in addition, the EPEL repository, which has a CentOS Stream 9 support.
How to install – Network installation of CentOS Stream 9 (20220606.0) – minimal server installation with additional information about important CentOS Stream 9 URLs and links and what kind of software the user can expect to have Software and technical details of CentOS Stream 9 minimal install. Camparing the packages of the two systems – a clean install of CentOS Stream 9 and an upgrade from CentOS Stream 8, the clean install has 377 packages installed and the upgrade has 387 packages installed. The strated processes are the same except the chronyd service is not started on boot. chronyd daemon offers a time synchronization.

STEP 1) All installed packages should be updated to the latest versions.

[root@srv ~]# dnf update -y
Last metadata expiration check: 0:09:08 ago on Tue Oct  4 12:12:07 2022.
Dependencies resolved.
Nothing to do.
Complete!

The DNF tool reports that all packages are up-to-date, because there is nothing to upgrade.

STEP 2) A cleanup of all packages, which are not required anymore.

Check orphan and leaves packages. Some of the packages here may be used by the user explicitly, so it is important to know the system. Remove the packages if not used by the system and they are showed as an output of the following commands and they are not used by the user of the system.

[root@srv ~]# dnf repoquery --unneeded
Last metadata expiration check: 0:12:56 ago on Tue Oct  4 12:12:07 2022.
NetworkManager-initscripts-updown-1:1.40.0-1.el8.noarch
grub2-tools-efi-1:2.02-129.el8.x86_64
libmetalink-0:0.1.3-7.el8.x86_64
pciutils-0:3.7.0-1.el8.x86_64
python3-configobj-0:5.0.6-11.el8.noarch
python3-schedutils-0:0.6-6.el8.x86_64
rdma-core-0:41.0-1.el8.x86_64
[root@srv ~]# dnf repoquery --extras
Last metadata expiration check: 0:00:12 ago on Tue Oct  4 12:34:17 2022.

Remove the unneeded packages:

[root@srv ~]# dnf remove -y NetworkManager-initscripts-updown-1:1.40.0-1.el8.noarch grub2-tools-efi-1:2.02-129.el8.x86_64  libmetalink-0:0.1.3-7.el8.x86_64 pciutils-0:3.7.0-1.el8.x86_64 python3-configobj-0:5.0.6-11.el8.noarch python3-schedutils-0:0.6-6.el8.x86_64 rdma-core-0:41.0-1.el8.x86_64
Dependencies resolved.
=========================================================================================
 Package                               Arch       Version            Repository     Size
=========================================================================================
Removing:
 NetworkManager-initscripts-updown     noarch     1:1.40.0-1.el8     @baseos       2.1 k
 grub2-tools-efi                       x86_64     1:2.02-129.el8     @baseos       2.0 M
 libmetalink                           x86_64     0.1.3-7.el8        @anaconda      75 k
 pciutils                              x86_64     3.7.0-1.el8        @anaconda     211 k
 python3-configobj                     noarch     5.0.6-11.el8       @anaconda     342 k
 python3-schedutils                    x86_64     0.6-6.el8          @anaconda      46 k
 rdma-core                             x86_64     41.0-1.el8         @baseos       103 k

Transaction Summary
=========================================================================================
Remove  7 Packages

Freed space: 2.8 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                 1/1 
  Running scriptlet: python3-configobj-5.0.6-11.el8.noarch                           1/1 
  Erasing          : python3-configobj-5.0.6-11.el8.noarch                           1/7 
  Running scriptlet: NetworkManager-initscripts-updown-1:1.40.0-1.el8.noarch         2/7 
  Erasing          : NetworkManager-initscripts-updown-1:1.40.0-1.el8.noarch         2/7 
  Erasing          : rdma-core-41.0-1.el8.x86_64                                     3/7 
  Running scriptlet: rdma-core-41.0-1.el8.x86_64                                     3/7 
  Erasing          : pciutils-3.7.0-1.el8.x86_64                                     4/7 
  Erasing          : python3-schedutils-0.6-6.el8.x86_64                             5/7 
  Erasing          : libmetalink-0.1.3-7.el8.x86_64                                  6/7 
  Erasing          : grub2-tools-efi-1:2.02-129.el8.x86_64                           7/7 
  Running scriptlet: grub2-tools-efi-1:2.02-129.el8.x86_64                           7/7 
  Verifying        : NetworkManager-initscripts-updown-1:1.40.0-1.el8.noarch         1/7 
  Verifying        : grub2-tools-efi-1:2.02-129.el8.x86_64                           2/7 
  Verifying        : libmetalink-0.1.3-7.el8.x86_64                                  3/7 
  Verifying        : pciutils-3.7.0-1.el8.x86_64                                     4/7 
  Verifying        : python3-configobj-5.0.6-11.el8.noarch                           5/7 
  Verifying        : python3-schedutils-0.6-6.el8.x86_64                             6/7 
  Verifying        : rdma-core-41.0-1.el8.x86_64                                     7/7 

Removed:
  NetworkManager-initscripts-updown-1:1.40.0-1.el8.noarch                                
  grub2-tools-efi-1:2.02-129.el8.x86_64                                                  
  libmetalink-0.1.3-7.el8.x86_64                                                         
  pciutils-3.7.0-1.el8.x86_64                                                            
  python3-configobj-5.0.6-11.el8.noarch                                                  
  python3-schedutils-0.6-6.el8.x86_64                                                    
  rdma-core-41.0-1.el8.x86_64                                                            

Complete!

In fact, some of the above packages may be left on the system, but it is better to remove them and if they are needed to be installed after the upgrade.

STEP 3)Install the CentOS Stream 9 repositories.

Three files should be installed:

  1. http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-stream-repos-9.0-18.el9.noarch.rpm
  2. http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-stream-release-9.0-18.el9.noarch.rpm
  3. http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-gpg-keys-9.0-18.el9.noarch.rpm

These are the latest version at the time of writing this article. Check the URL http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/ for newer versions.

main menu
The CentOS Stream 9 repository RPMs.

[root@srv ~]# dnf install -y http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-stream-repos-9.0-18.el9.noarch.rpm http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-stream-release-9.0-18.el9.noarch.rpm http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-gpg-keys-9.0-18.el9.noarch.rpm
Last metadata expiration check: 0:01:37 ago on Tue Oct  4 12:59:52 2022.
centos-stream-repos-9.0-18.el9.noarch.rpm                 47 kB/s |  12 kB     00:00    
centos-stream-release-9.0-18.el9.noarch.rpm               92 kB/s |  26 kB     00:00    
centos-gpg-keys-9.0-18.el9.noarch.rpm                     77 kB/s |  15 kB     00:00    
Dependencies resolved.
=========================================================================================
 Package                      Architecture  Version            Repository           Size
=========================================================================================
Upgrading:
 centos-stream-release        noarch        9.0-18.el9         @commandline         26 k
 centos-stream-repos          noarch        9.0-18.el9         @commandline         12 k
Downgrading:
 centos-gpg-keys              noarch        9.0-18.el9         @commandline         15 k

Transaction Summary
=========================================================================================
Upgrade    2 Packages
Downgrade  1 Package

Total size: 53 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                 1/1 
  Running scriptlet: centos-gpg-keys-9.0-18.el9.noarch                               1/1 
  Downgrading      : centos-gpg-keys-9.0-18.el9.noarch                               1/6 
  Upgrading        : centos-stream-repos-9.0-18.el9.noarch                           2/6 
  Upgrading        : centos-stream-release-9.0-18.el9.noarch                         3/6 
  Cleanup          : centos-stream-release-8.6-1.el8.noarch                          4/6 
  Cleanup          : centos-stream-repos-8-6.el8.noarch                              5/6 
  Cleanup          : centos-gpg-keys-1:8-6.el8.noarch                                6/6 
  Running scriptlet: centos-gpg-keys-1:8-6.el8.noarch                                6/6 
Line is not an assignment at '/usr/lib/sysctl.d/50-redhat.conf:7': (null)
Couldn't write '1' to 'net/ipv4/conf/*/rp_filter', ignoring: No such file or directory
warning: %transfiletriggerin(systemd-239-67.el8.x86_64) scriptlet failed, exit status 1

Error in <unknown> scriptlet in rpm package centos-gpg-keys
  Verifying        : centos-gpg-keys-9.0-18.el9.noarch                               1/6 
  Verifying        : centos-gpg-keys-1:8-6.el8.noarch                                2/6 
  Verifying        : centos-stream-repos-9.0-18.el9.noarch                           3/6 
  Verifying        : centos-stream-repos-8-6.el8.noarch                              4/6 
  Verifying        : centos-stream-release-9.0-18.el9.noarch                         5/6 
  Verifying        : centos-stream-release-8.6-1.el8.noarch                          6/6 

Upgraded:
  centos-stream-release-9.0-18.el9.noarch      centos-stream-repos-9.0-18.el9.noarch     
Downgraded:
  centos-gpg-keys-9.0-18.el9.noarch                                                      

Complete!

Upgrade the distro with

[root@srv ~]# dnf -y --releasever=9-stream --allowerasing --setopt=deltarpm=false distro-sync
CentOS Stream 9-stream - BaseOS                          1.8 MB/s | 5.9 MB     00:03    
CentOS Stream 9-stream - AppStream                       3.2 MB/s |  15 MB     00:04    
CentOS Stream 9-stream - Extras packages                 7.2 kB/s | 8.7 kB     00:01    
Extra Packages for Enterprise Linux 8 - x86_64           2.3 MB/s |  13 MB     00:05    
Extra Packages for Enterprise Linux Modular 8 - x86_64   596 kB/s | 733 kB     00:01    
Extra Packages for Enterprise Linux 8 - Next - x86_64    2.0 MB/s | 1.4 MB     00:00    
Dependencies resolved.
=========================================================================================
 Package                       Arch   Version                        Repository     Size
=========================================================================================
Installing:
 kernel                        x86_64 5.14.0-171.el9                 baseos        1.9 M
 kernel-core                   x86_64 5.14.0-171.el9                 baseos         46 M
 kernel-modules                x86_64 5.14.0-171.el9                 baseos         34 M
Upgrading:
 NetworkManager                x86_64 1:1.40.0-1.el9                 baseos        2.2 M
 NetworkManager-libnm          x86_64 1:1.40.0-1.el9                 baseos        1.7 M
 NetworkManager-team           x86_64 1:1.40.0-1.el9                 baseos         36 k
 NetworkManager-tui            x86_64 1:1.40.0-1.el9                 baseos        231 k
 acl                           x86_64 2.3.1-3.el9                    baseos         73 k
 audit                         x86_64 3.0.7-103.el9                  baseos        272 k
 audit-libs                    x86_64 3.0.7-103.el9                  baseos        118 k
 authselect                    x86_64 1.2.5-1.el9                    baseos        144 k
 authselect-libs               x86_64 1.2.5-1.el9                    baseos        243 k
 basesystem                    noarch 11-13.el9                      baseos        3.9 k
 bash                          x86_64 5.1.8-5.el9                    baseos        1.7 M
 biosdevname                   x86_64 0.7.3-9.el9                    baseos         36 k
......
......
 subscription-manager          x86_64 1.29.30-1.el9                  baseos        900 k
     replacing  python3-syspurpose.x86_64 1.28.28-1.el8
 subscription-manager-rhsm-certificates
                               noarch 20220623-1.el9                 baseos         21 k
 systemd-rpm-macros            noarch 250-11.el9                     baseos         43 k
 usermode                      x86_64 1.114-4.el9                    baseos        190 k
 userspace-rcu                 x86_64 0.12.1-6.el9                   baseos        110 k
 util-linux-core               x86_64 2.37.4-9.el9                   baseos        461 k
     replacing  hardlink.x86_64 1:1.3-6.el8
Installing weak dependencies:
 gawk-all-langpacks            x86_64 5.1.0-6.el9                    appstream     207 k
 libcap-ng-python3             x86_64 0.8.2-7.el9                    appstream      30 k
 libxcrypt-compat              x86_64 4.4.18-3.el9                   appstream      89 k
 python-unversioned-command    noarch 3.9.14-1.el9                   appstream      12 k
 rsyslog-logrotate             x86_64 8.2102.0-105.el9               appstream      12 k
 zstd                          x86_64 1.5.1-2.el9                    baseos        548 k
Removing:
 kernel                        x86_64 4.18.0-338.el8                 @baseos         0  
 kernel-core                   x86_64 4.18.0-338.el8                 @baseos        68 M
 kernel-modules                x86_64 4.18.0-338.el8                 @baseos        22 M
Removing dependent packages:
 gdbm                          x86_64 1:1.18-2.el8                   @baseos       381 k
 python3-slip                  noarch 0.6.4-13.el8                   @baseos        60 k
 python3-slip-dbus             noarch 0.6.4-13.el8                   @baseos        70 k
Downgrading:
 ethtool                       x86_64 2:5.10-4.el9                   baseos        212 k
 libldb                        x86_64 2.5.2-1.el9                    baseos        187 k
 libtalloc                     x86_64 2.3.3-1.el9                    baseos         32 k
 linux-firmware                noarch 20220708-127.el9               baseos        233 M
 memstrack                     x86_64 0.2.4-1.el9                    appstream      50 k

Transaction Summary
=========================================================================================
Install     53 Packages
Upgrade    333 Packages
Remove       6 Packages
Downgrade    5 Packages

Total download size: 530 M
Downloading Packages:
(1/391): libtalloc-2.3.3-1.el9.x86_64.rpm                 38 kB/s |  32 kB     00:00    
......
......
(391/391): linux-firmware-20220708-127.el9.noarch.rpm    956 kB/s | 233 MB     04:09    
-----------------------------------------------------------------------------------------
Total                                                    2.1 MB/s | 530 MB     04:14     
CentOS Stream 9-stream - Extras packages                 2.1 MB/s | 2.1 kB     00:00    
Importing GPG key 0x1D997668:
 Userid     : "CentOS Extras SIG (https://wiki.centos.org/SpecialInterestGroup) <security@centos.org>"
 Fingerprint: 363F C097 2F64 B699 AED3 968E 1FF6 A217 1D99 7668
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Running scriptlet: filesystem-3.16-2.el9.x86_64                                    1/1 
  Running scriptlet: selinux-policy-targeted-34.1.43-1.el9.noarch                    1/1 
  Running scriptlet: firewalld-1.0.0-2.el9.noarch                                    1/1 
  Preparing        :                                                                 1/1 
  Running scriptlet: libgcc-11.3.1-2.1.el9.x86_64                                    1/1 
  Upgrading        : libgcc-11.3.1-2.1.el9.x86_64                                  1/742 
  Running scriptlet: libgcc-11.3.1-2.1.el9.x86_64                                  1/742 
  Installing       : linux-firmware-whence-20220708-127.el9.noarch                 2/742 
  Upgrading        : crypto-policies-20220815-1.git0fbe86f.el9.noarch              3/742 
  Running scriptlet: crypto-policies-20220815-1.git0fbe86f.el9.noarch              3/742 
  Upgrading        : setup-2.13.7-7.el9.noarch                                     4/742 
warning: /etc/shadow created as /etc/shadow.rpmnew

  Running scriptlet: setup-2.13.7-7.el9.noarch                                     4/742 
.......
.......
  util-linux-core-2.37.4-9.el9.x86_64                                                    
  zstd-1.5.1-2.el9.x86_64                                                                
Removed:
  gdbm-1:1.18-2.el8.x86_64                  kernel-4.18.0-338.el8.x86_64                 
  kernel-core-4.18.0-338.el8.x86_64         kernel-modules-4.18.0-338.el8.x86_64         
  python3-slip-0.6.4-13.el8.noarch          python3-slip-dbus-0.6.4-13.el8.noarch        

Complete!

Rebuild the RPM database.

[root@srv ~]# rpmdb --rebuilddb
warning: Converting database from bdb_ro to sqlite backend
[root@srv ~]#

Clean DNF cache:

[root@srv ~]# dnf clean packages
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

0 files removed

Issue the update command again:

[root@srv ~]# dnf update -y
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

Last metadata expiration check: 3:28:41 ago on Tue Oct  4 13:32:49 2022.
Dependencies resolved.
=========================================================================================
 Package                          Architecture  Version              Repository     Size
=========================================================================================
Upgrading:
 epel-next-release                noarch        9-4.el9              epel          8.2 k
 epel-release                     noarch        9-4.el9              epel           18 k
 initscripts                      x86_64        10.11.5-1.el9        baseos        230 k
 initscripts-service              noarch        10.11.5-1.el9        baseos         14 k
 trousers                         x86_64        0.3.15-5.el9         epel          144 k
 trousers-lib                     x86_64        0.3.15-5.el9         epel          165 k
Installing dependencies:
 initscripts-rename-device        x86_64        10.11.5-1.el9        baseos         17 k

Transaction Summary
=========================================================================================
Install  1 Package
Upgrade  6 Packages

Total size: 598 k
Total download size: 581 k
Downloading Packages:
[SKIPPED] initscripts-rename-device-10.11.5-1.el9.x86_64.rpm: Already downloaded        
(2/7): epel-next-release-9-4.el9.noarch.rpm               41 kB/s | 8.2 kB     00:00    
(3/7): epel-release-9-4.el9.noarch.rpm                   838 kB/s |  18 kB     00:00    
(4/7): initscripts-service-10.11.5-1.el9.noarch.rpm       46 kB/s |  14 kB     00:00    
(5/7): trousers-0.3.15-5.el9.x86_64.rpm                  1.5 MB/s | 144 kB     00:00    
(6/7): trousers-lib-0.3.15-5.el9.x86_64.rpm              1.5 MB/s | 165 kB     00:00    
(7/7): initscripts-10.11.5-1.el9.x86_64.rpm              349 kB/s | 230 kB     00:00    
-----------------------------------------------------------------------------------------
Total                                                    222 kB/s | 581 kB     00:02     
Extra Packages for Enterprise Linux 9 - x86_64           1.6 MB/s | 1.6 kB     00:00    
Importing GPG key 0x3228467C:
 Userid     : "Fedora (epel9) <epel@fedoraproject.org>"
 Fingerprint: FF8A D134 4597 106E CE81 3B91 8A38 72BF 3228 467C
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-9
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                 1/1 
  Upgrading        : epel-release-9-4.el9.noarch                                    1/13 
warning: Unable to get systemd shutdown inhibition lock: Failed to activate service 'org.freedesktop.login1': timed out (service_start_timeout=25000ms)

  Running scriptlet: epel-release-9-4.el9.noarch                                    1/13 
  Upgrading        : epel-next-release-9-4.el9.noarch                               2/13 
  Upgrading        : trousers-lib-0.3.15-5.el9.x86_64                               3/13 
  Upgrading        : initscripts-service-10.11.5-1.el9.noarch                       4/13 
  Installing       : initscripts-rename-device-10.11.5-1.el9.x86_64                 5/13 
  Upgrading        : initscripts-10.11.5-1.el9.x86_64                               6/13 
  Running scriptlet: initscripts-10.11.5-1.el9.x86_64                               6/13 
  Running scriptlet: trousers-0.3.15-5.el9.x86_64                                   7/13 
  Upgrading        : trousers-0.3.15-5.el9.x86_64                                   7/13 
  Running scriptlet: trousers-0.3.15-5.el9.x86_64                                   7/13 
  Cleanup          : epel-next-release-9-2.el9.noarch                               8/13 
  Running scriptlet: trousers-0.3.15-1.el8.x86_64                                   9/13 
  Cleanup          : trousers-0.3.15-1.el8.x86_64                                   9/13 
  Running scriptlet: trousers-0.3.15-1.el8.x86_64                                   9/13 
  Running scriptlet: initscripts-10.11.2-1.el9.x86_64                              10/13 
  Cleanup          : initscripts-10.11.2-1.el9.x86_64                              10/13 
  Running scriptlet: initscripts-10.11.2-1.el9.x86_64                              10/13 
  Cleanup          : initscripts-service-10.11.2-1.el9.noarch                      11/13 
  Cleanup          : epel-release-9-2.el9.noarch                                   12/13 
  Cleanup          : trousers-lib-0.3.15-1.el8.x86_64                              13/13 
  Running scriptlet: trousers-lib-0.3.15-1.el8.x86_64                              13/13 
  Verifying        : initscripts-rename-device-10.11.5-1.el9.x86_64                 1/13 
  Verifying        : initscripts-10.11.5-1.el9.x86_64                               2/13 
  Verifying        : initscripts-10.11.2-1.el9.x86_64                               3/13 
  Verifying        : initscripts-service-10.11.5-1.el9.noarch                       4/13 
  Verifying        : initscripts-service-10.11.2-1.el9.noarch                       5/13 
  Verifying        : epel-next-release-9-4.el9.noarch                               6/13 
  Verifying        : epel-next-release-9-2.el9.noarch                               7/13 
  Verifying        : epel-release-9-4.el9.noarch                                    8/13 
  Verifying        : epel-release-9-2.el9.noarch                                    9/13 
  Verifying        : trousers-0.3.15-5.el9.x86_64                                  10/13 
  Verifying        : trousers-0.3.15-1.el8.x86_64                                  11/13 
  Verifying        : trousers-lib-0.3.15-5.el9.x86_64                              12/13 
  Verifying        : trousers-lib-0.3.15-1.el8.x86_64                              13/13 
Installed products updated.

Upgraded:
  epel-next-release-9-4.el9.noarch        epel-release-9-4.el9.noarch                    
  initscripts-10.11.5-1.el9.x86_64        initscripts-service-10.11.5-1.el9.noarch       
  trousers-0.3.15-5.el9.x86_64            trousers-lib-0.3.15-5.el9.x86_64               
Installed:
  initscripts-rename-device-10.11.5-1.el9.x86_64                                         

Complete!

Install all packages for “Minimal Install”:

[root@srv ~]# dnf -y groupupdate "Core" "Minimal Install"
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

Last metadata expiration check: 0:01:02 ago on Tue Oct  4 17:02:07 2022.
Dependencies resolved.
=========================================================================================
 Package                  Architecture   Version                    Repository      Size
=========================================================================================
Installing group/module packages:
 iproute-tc               x86_64         5.18.0-1.el9               baseos         461 k
 rpm-plugin-audit         x86_64         4.16.1.3-17.el9            baseos          18 k
Installing Environment Groups:
 Minimal Install                                                                        
Installing Groups:
 Core                                                                                   

Transaction Summary
=========================================================================================
Install  2 Packages

Total download size: 478 k
Installed size: 937 k
Downloading Packages:
(1/2): rpm-plugin-audit-4.16.1.3-17.el9.x86_64.rpm        26 kB/s |  18 kB     00:00    
(2/2): iproute-tc-5.18.0-1.el9.x86_64.rpm                469 kB/s | 461 kB     00:00    
-----------------------------------------------------------------------------------------
Total                                                    188 kB/s | 478 kB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                 1/1 
  Installing       : rpm-plugin-audit-4.16.1.3-17.el9.x86_64                         1/2 
warning: Unable to get systemd shutdown inhibition lock: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

  Installing       : iproute-tc-5.18.0-1.el9.x86_64                                  2/2 
  Running scriptlet: iproute-tc-5.18.0-1.el9.x86_64                                  2/2 
  Verifying        : iproute-tc-5.18.0-1.el9.x86_64                                  1/2 
  Verifying        : rpm-plugin-audit-4.16.1.3-17.el9.x86_64                         2/2 
Installed products updated.

Installed:
  iproute-tc-5.18.0-1.el9.x86_64         rpm-plugin-audit-4.16.1.3-17.el9.x86_64        

Complete!

Now the system is upgraded to the CentOS Stream 9. The system should be restarted.

[root@srv ~]# cat /etc/*release
CentOS Stream release 9
NAME="CentOS Stream"
VERSION="9"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="9"
PLATFORM_ID="platform:el9"
PRETTY_NAME="CentOS Stream 9"
ANSI_COLOR="0;31"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:centos:centos:9"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 9"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"
CentOS Stream release 9
CentOS Stream release 9

STEP 4) Additional cleanups.

Remove the old kernels and all old packages, which have in the version “.el8” for CentOS Stream 8.
First, remove the old kernels:

[root@srv ~]# rpm -q kernel-core
kernel-core-4.18.0-383.el8.x86_64
kernel-core-4.18.0-408.el8.x86_64
kernel-core-5.14.0-171.el9.x86_64
[root@srv ~]# dnf remove -y kernel-core-4.18.0-383.el8.x86_64 kernel-core-4.18.0-408.el8.x86_64
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

Dependencies resolved.
=========================================================================================
 Package                 Architecture    Version                  Repository        Size
=========================================================================================
Removing:
 kernel-core             x86_64          4.18.0-383.el8           @baseos           69 M
 kernel-core             x86_64          4.18.0-408.el8           @baseos           69 M
Removing dependent packages:
 kernel                  x86_64          4.18.0-383.el8           @baseos            0  
 kernel                  x86_64          4.18.0-408.el8           @baseos            0  
 kernel-modules          x86_64          4.18.0-383.el8           @baseos           23 M
 kernel-modules          x86_64          4.18.0-408.el8           @baseos           23 M

Transaction Summary
=========================================================================================
Remove  6 Packages

Freed space: 184 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                 1/1 
  Erasing          : kernel-4.18.0-383.el8.x86_64                                    1/6 
  Running scriptlet: kernel-4.18.0-383.el8.x86_64                                    1/6 
  Erasing          : kernel-4.18.0-408.el8.x86_64                                    2/6 
  Running scriptlet: kernel-4.18.0-408.el8.x86_64                                    2/6 
  Erasing          : kernel-modules-4.18.0-408.el8.x86_64                            3/6 
  Running scriptlet: kernel-modules-4.18.0-408.el8.x86_64                            3/6 
  Erasing          : kernel-modules-4.18.0-383.el8.x86_64                            4/6 
  Running scriptlet: kernel-modules-4.18.0-383.el8.x86_64                            4/6 
  Running scriptlet: kernel-core-4.18.0-383.el8.x86_64                               5/6 
  Erasing          : kernel-core-4.18.0-383.el8.x86_64                               5/6 
  Running scriptlet: kernel-core-4.18.0-383.el8.x86_64                               5/6 
  Running scriptlet: kernel-core-4.18.0-408.el8.x86_64                               6/6 
  Erasing          : kernel-core-4.18.0-408.el8.x86_64                               6/6 
  Running scriptlet: kernel-core-4.18.0-408.el8.x86_64                               6/6 
  Verifying        : kernel-4.18.0-408.el8.x86_64                                    1/6 
  Verifying        : kernel-4.18.0-383.el8.x86_64                                    2/6 
  Verifying        : kernel-core-4.18.0-383.el8.x86_64                               3/6 
  Verifying        : kernel-core-4.18.0-408.el8.x86_64                               4/6 
  Verifying        : kernel-modules-4.18.0-408.el8.x86_64                            5/6 
  Verifying        : kernel-modules-4.18.0-383.el8.x86_64                            6/6 
Installed products updated.

Removed:
  kernel-4.18.0-383.el8.x86_64                kernel-4.18.0-408.el8.x86_64               
  kernel-core-4.18.0-383.el8.x86_64           kernel-core-4.18.0-408.el8.x86_64          
  kernel-modules-4.18.0-383.el8.x86_64        kernel-modules-4.18.0-408.el8.x86_64       

Complete!

Remove the Subscription Manager if you do not have a subscription:

[root@srv ~]# dnf remove -y subscription-manager 
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

Dependencies resolved.
=========================================================================================
 Package                                   Arch      Version            Repository  Size
=========================================================================================
Removing:
 subscription-manager                      x86_64    1.29.30-1.el9      @baseos    3.2 M
Removing unused dependencies:
 libdnf-plugin-subscription-manager        x86_64    1.29.30-1.el9      @baseos     63 k
 python3-chardet                           noarch    4.0.0-5.el9        @baseos    1.4 M
 python3-cloud-what                        x86_64    1.29.30-1.el9      @baseos     73 k
 python3-decorator                         noarch    4.4.2-6.el9        @baseos     61 k
 python3-ethtool                           x86_64    0.15-2.el9         @baseos     94 k
 python3-idna                              noarch    2.10-7.el9         @baseos    459 k
 python3-iniparse                          noarch    0.4-45.el9         @baseos    106 k
 python3-inotify                           noarch    0.9.6-25.el9       @baseos    244 k
 python3-librepo                           x86_64    1.14.2-3.el9       @baseos    183 k
 python3-pysocks                           noarch    1.7.1-12.el9       @baseos     88 k
 python3-requests                          noarch    2.25.1-6.el9       @baseos    389 k
 python3-setuptools                        noarch    53.0.0-11.el9      @baseos    4.2 M
 python3-subscription-manager-rhsm         x86_64    1.29.30-1.el9      @baseos    431 k
 python3-urllib3                           noarch    1.26.5-3.el9       @baseos    728 k
 subscription-manager-rhsm-certificates    noarch    20220623-1.el9     @baseos     27 k
 usermode                                  x86_64    1.114-4.el9        @baseos    836 k

Transaction Summary
=========================================================================================
Remove  17 Packages

Freed space: 12 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                 1/1 
  Running scriptlet: subscription-manager-1.29.30-1.el9.x86_64                      1/17 
Removed "/etc/systemd/system/multi-user.target.wants/rhsmcertd.service".

  Erasing          : subscription-manager-1.29.30-1.el9.x86_64                      1/17 
  Running scriptlet: subscription-manager-1.29.30-1.el9.x86_64                      1/17 
  Erasing          : python3-subscription-manager-rhsm-1.29.30-1.el9.x86_64         2/17 
  Erasing          : python3-cloud-what-1.29.30-1.el9.x86_64                        3/17 
  Erasing          : python3-requests-2.25.1-6.el9.noarch                           4/17 
  Erasing          : python3-urllib3-1.26.5-3.el9.noarch                            5/17 
  Erasing          : python3-inotify-0.9.6-25.el9.noarch                            6/17 
  Erasing          : python3-setuptools-53.0.0-11.el9.noarch                        7/17 
  Erasing          : python3-idna-2.10-7.el9.noarch                                 8/17 
  Erasing          : python3-pysocks-1.7.1-12.el9.noarch                            9/17 
  Erasing          : python3-chardet-4.0.0-5.el9.noarch                            10/17 
  Erasing          : python3-iniparse-0.4-45.el9.noarch                            11/17 
  Erasing          : subscription-manager-rhsm-certificates-20220623-1.el9.noarc   12/17 
  Erasing          : python3-decorator-4.4.2-6.el9.noarch                          13/17 
  Erasing          : libdnf-plugin-subscription-manager-1.29.30-1.el9.x86_64       14/17 
  Erasing          : python3-ethtool-0.15-2.el9.x86_64                             15/17 
  Erasing          : python3-librepo-1.14.2-3.el9.x86_64                           16/17 
  Erasing          : usermode-1.114-4.el9.x86_64                                   17/17 
  Running scriptlet: usermode-1.114-4.el9.x86_64                                   17/17 
  Verifying        : libdnf-plugin-subscription-manager-1.29.30-1.el9.x86_64        1/17 
  Verifying        : python3-chardet-4.0.0-5.el9.noarch                             2/17 
  Verifying        : python3-cloud-what-1.29.30-1.el9.x86_64                        3/17 
  Verifying        : python3-decorator-4.4.2-6.el9.noarch                           4/17 
  Verifying        : python3-ethtool-0.15-2.el9.x86_64                              5/17 
  Verifying        : python3-idna-2.10-7.el9.noarch                                 6/17 
  Verifying        : python3-iniparse-0.4-45.el9.noarch                             7/17 
  Verifying        : python3-inotify-0.9.6-25.el9.noarch                            8/17 
  Verifying        : python3-librepo-1.14.2-3.el9.x86_64                            9/17 
  Verifying        : python3-pysocks-1.7.1-12.el9.noarch                           10/17 
  Verifying        : python3-requests-2.25.1-6.el9.noarch                          11/17 
  Verifying        : python3-setuptools-53.0.0-11.el9.noarch                       12/17 
  Verifying        : python3-subscription-manager-rhsm-1.29.30-1.el9.x86_64        13/17 
  Verifying        : python3-urllib3-1.26.5-3.el9.noarch                           14/17 
  Verifying        : subscription-manager-1.29.30-1.el9.x86_64                     15/17 
  Verifying        : subscription-manager-rhsm-certificates-20220623-1.el9.noarc   16/17 
  Verifying        : usermode-1.114-4.el9.x86_64                                   17/17 

Removed:
  libdnf-plugin-subscription-manager-1.29.30-1.el9.x86_64                                
  python3-chardet-4.0.0-5.el9.noarch                                                     
  python3-cloud-what-1.29.30-1.el9.x86_64                                                
  python3-decorator-4.4.2-6.el9.noarch                                                   
  python3-ethtool-0.15-2.el9.x86_64                                                      
  python3-idna-2.10-7.el9.noarch                                                         
  python3-iniparse-0.4-45.el9.noarch                                                     
  python3-inotify-0.9.6-25.el9.noarch                                                    
  python3-librepo-1.14.2-3.el9.x86_64                                                    
  python3-pysocks-1.7.1-12.el9.noarch                                                    
  python3-requests-2.25.1-6.el9.noarch                                                   
  python3-setuptools-53.0.0-11.el9.noarch                                                
  python3-subscription-manager-rhsm-1.29.30-1.el9.x86_64                                 
  python3-urllib3-1.26.5-3.el9.noarch                                                    
  subscription-manager-1.29.30-1.el9.x86_64                                              
  subscription-manager-rhsm-certificates-20220623-1.el9.noarch                           
  usermode-1.114-4.el9.x86_64                                                            

Complete!

List all packages with .el8, which means they are from CentOS Stream 8:

[root@srv ~]# dnf list --installed|grep el8
inih.x86_64                        56-1.el8                        @epel        
iwl6000-firmware.noarch            9.221.4.1-110.el8.1             @baseos      
libcbor.x86_64                     0.7.0-6.el8                     @epel        
libcroco.x86_64                    0.6.12-4.el8_2.1                @anaconda    
libfido2.x86_64                    1.11.0-2.el8                    @epel        
mozjs60.x86_64                     60.9.0-4.el8                    @anaconda

These are old libraries or modules, which old versions are not included in CentOS Stream 9 release. The best way is to search their equivalents in CentOS Stream 9 and to install those packages. It’s safe to remove them if not used.
For example, inih library is older version in CentOS Stream 9, than the CentOS Stream 8. inih in CentOS Stream 8 is from EPEL repo, but in CentOS Stream 9 is from the baseos. In rear cases, it may happen the packages in the new CentOS release to be a little bit older than the EPEL package from the old CentOS release.

[root@srv ~]# dnf info inih
Last metadata expiration check: 0:27:12 ago on Tue 04 Oct 2022 05:02:07 PM UTC.
Installed Packages
Name         : inih
Version      : 56
Release      : 1.el8
Architecture : x86_64
Size         : 47 k
Source       : inih-56-1.el8.src.rpm
Repository   : @System
From repo    : epel
Summary      : Simple INI file parser library
URL          : https://github.com/benhoyt/inih
License      : BSD
Description  : The inih package provides simple INI file parser which is only a couple of
             : pages of code, and it was designed to be small and simple, so it's good
             : for embedded systems.

Available Packages
Name         : inih
Version      : 49
Release      : 6.el9
Architecture : i686
Size         : 18 k
Source       : inih-49-6.el9.src.rpm
Repository   : baseos
Summary      : Simple INI file parser library
URL          : https://github.com/benhoyt/inih
License      : BSD
Description  : The inih package provides simple INI file parser which is only a couple of
             : pages of code, and it was designed to be small and simple, so it's good
             : for embedded systems.

[root@srv ~]# dnf remove -y inih-56-1.el8
Dependencies resolved.
=========================================================================================
 Package                 Architecture     Version                Repository         Size
=========================================================================================
Removing:
 inih                    x86_64           56-1.el8               @epel              47 k
Removing dependent packages:
 xfsprogs                x86_64           5.14.2-1.el9           @baseos           3.3 M
Removing unused dependencies:
 userspace-rcu           x86_64           0.12.1-6.el9           @baseos           408 k

Transaction Summary
=========================================================================================
Remove  3 Packages

Freed space: 3.7 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                 1/1 
  Erasing          : xfsprogs-5.14.2-1.el9.x86_64                                    1/3 
  Erasing          : inih-56-1.el8.x86_64                                            2/3 
  Erasing          : userspace-rcu-0.12.1-6.el9.x86_64                               3/3 
  Running scriptlet: userspace-rcu-0.12.1-6.el9.x86_64                               3/3 
  Verifying        : inih-56-1.el8.x86_64                                            1/3 
  Verifying        : userspace-rcu-0.12.1-6.el9.x86_64                               2/3 
  Verifying        : xfsprogs-5.14.2-1.el9.x86_64                                    3/3 

Removed:
  inih-56-1.el8.x86_64  userspace-rcu-0.12.1-6.el9.x86_64  xfsprogs-5.14.2-1.el9.x86_64 

Complete!
[root@srv ~]# dnf install -y inih
Last metadata expiration check: 0:27:31 ago on Tue 04 Oct 2022 05:02:07 PM UTC.
Dependencies resolved.
=========================================================================================
 Package           Architecture        Version                 Repository           Size
=========================================================================================
Installing:
 inih              x86_64              49-6.el9                baseos               18 k

Transaction Summary
=========================================================================================
Install  1 Package

Total download size: 18 k
Installed size: 26 k
Downloading Packages:
inih-49-6.el9.x86_64.rpm                                  92 kB/s |  18 kB     00:00    
-----------------------------------------------------------------------------------------
Total                                                     26 kB/s |  18 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                 1/1 
  Installing       : inih-49-6.el9.x86_64                                            1/1 
  Running scriptlet: inih-49-6.el9.x86_64                                            1/1 
  Verifying        : inih-49-6.el9.x86_64                                            1/1 

Installed:
  inih-49-6.el9.x86_64                                                                   

Complete!

To use the CentOS Stream 9 package just remove the old one and then install it again as above.

STEP 5) Regenerate the rescue kernel boot entry.

. The rescue kernel is the old one (as shown in the screenshot at the start of the article), so it should be generated for the new CentOS release, i.e. the current kernel. Check out the this article on the subject for detailed information – Generate the rescue kernel boot entry in CentOS Stream 9
Here is what should do:

[root@srv ~]# rm -f /boot/vmlinuz-0-rescue-b2a198ecbfdd451cb905f76f825af01e /boot/initramfs-0-rescue-b2a198ecbfdd451cb905f76f825af01e.img /boot/loader/entries/b2a198ecbfdd451cb905f76f825af01e-0-rescue.conf
[root@srv ~]# /usr/lib/kernel/install.d/51-dracut-rescue.install add $(uname -r) /boot /boot/vmlinuz-$(uname -r)

The command does not print output on a successful rescue kernel generation.

STEP 6) DNF broken modules.

It appears some DNF modules may get broken and the DNF manager reports it. Just resets the modules to their original state with:

[root@srv ~]# dnf module reset -y nodejs perl perl-IO-Socket-SSL perl-libwww-perl php satellite-5-client virt
Last metadata expiration check: 3:41:15 ago on Wed Oct 12 09:36:22 2022.
Modular dependency problems:

 Problem 1: conflicting requests
  - nothing provides module(platform:el8) needed by module nodejs:10:8030020210304194401:30b713e6.x86_64
 Problem 2: conflicting requests
  - nothing provides module(platform:el8) needed by module perl:5.26:8000020190628020724:55190bc5.x86_64
 Problem 3: conflicting requests
  - nothing provides module(platform:el8) needed by module perl-IO-Socket-SSL:2.066:8030020201222215140:1e4bbb35.x86_64
 Problem 4: conflicting requests
  - nothing provides module(platform:el8) needed by module perl-libwww-perl:6.34:8030020201223164340:b967a9a2.x86_64
 Problem 5: conflicting requests
  - nothing provides module(platform:el8) needed by module php:7.2:8020020200507003613:2c7ca891.x86_64
  - nothing provides module(httpd:2.4) needed by module php:7.2:8020020200507003613:2c7ca891.x86_64
  - nothing provides module(nginx) needed by module php:7.2:8020020200507003613:2c7ca891.x86_64
 Problem 6: conflicting requests
  - nothing provides module(platform:el8) needed by module satellite-5-client:1.0:8010020191114035551:cdc1202b.x86_64
 Problem 7: conflicting requests
  - nothing provides module(platform:el8) needed by module virt:rhel:8050020211221192853:b4937e53.x86_64
Dependencies resolved.
==============================================================================================================
 Package                   Architecture             Version                   Repository                 Size
==============================================================================================================
Resetting modules:
 nodejs                                                                                                      
 perl                                                                                                        
 perl-IO-Socket-SSL                                                                                          
 perl-libwww-perl                                                                                            
 php                                                                                                         
 satellite-5-client                                                                                          
 virt                                                                                                        

Transaction Summary
==============================================================================================================

Complete!

The broken modules are shown in every DNF command and after resetting them the output of the problem will disappear. More on the subject – DNF install and conflicting requests – nothing provides module(platform:el8) needed by module

STEP 7) Firewall changes.

When adding a masquerade to the forward packages in an inner interface as bridges, for example, it should be added explicit forward to the zone if the interfaces are in the same zone or explicitly intra-zone forward if the interfaces are in different zones:

firewall-cmd --permanent --zone=public --add-forward
firewall-cmd --reload

In simple words, if the Internet to all the virtual servers has stopped after the upgrade, add the “–add-forward” to the zone. If the interfaces are not in the same zone (i.e. public, for example) check the following link – https://bugzilla.redhat.com/show_bug.cgi?id=2016864

3 thoughts on “How to upgrade to CentOS Stream 9 from CentOS Stream 8”

  1. Hi,

    I cannot thank you enough for writing such an accurate article.

    on replacing the el8 packages like inih, I found that using “dnf swap” helps to preserve the dependencies:

    dnf swap inih-56-1.el8 inih-49-6.el

  2. I can’t thank you enough for this excellent article.
    The best advice on stackexchange is to install from scratch, but I have a RAID system under LVN and anaconda just saw it as four drives. Hard stop on that path! Also I didn’t fancy the idea of doing a backup and recovery of 2 TB into the cloud somewhere. This guide was a lifesaver.

    Ond thing I’d add. I had some problems with SELinux not allowing some operations. Rather then figure out exactly what selinux was unhappy with I just set selinux in permissive mode and continued.

Leave a Reply

Your email address will not be published. Required fields are marked *