Author: Vivek Gite
Step 1 – Backup
Like every seasoned developer and sysadmin, I backed up all my project files, MySQL database and config files. So if something goes wrong, I should be able to go back quickly. That is all. Hence, keep verified backups. I have following software installed:
- ELEP repo enabled for CentOS 8
- SELinux and FirewallD on CentOS 8 enabled
- Python 3.6.8.
- python3-mod_wsgi.
- Perl 5.26.3.
- mod_perl 2.0.11-4.
- Apache (httpd) 2.4.37 with mod_ssl, mod_security, mod_session, mod_speedycgi and other modules.
Do note down and list enabled repos:# yum repolist
# yum repolist enabled > /root/pre.update.dnf.repo.txt
Step 2 – Installing all updates on CentOS 8
Login using the ssh command:ssh {userName}@{your-Server-Name-IP-Here}
# for example:
ssh vivek@nixcraft-centos-httpd
Next, simply run the dnf command:sudo dnf update
Then reboot the Linux box using the shutdown command or reboot command:sudo shutdown -r now
Let us verify CentOS Linux 8 version using the cat command/more command or less command:more /etc/centos-release
Step 3 – Installing CentOS Stream package
Let us install the CentOS-Stream release file by typing the following dnf command:sudo dnf in centos-release-stream
Step 4 – Migrating From CentOS 8 to CentOS Stream
Now we have the required package is in place. In other words, the dnf is ready to provide a simple way for us to start migrating from CentOS 8 to CentOS Stream. But, first, we must swap repos. The following command will remove CentOS 8 repo and replace it with the CentOS Stream repo. We will get all updates and libs/apps from CentOS Stream. Execute the following command:sudo dnf swap centos-linux-repos centos-stream-repos
Last metadata expiration check: 0:07:46 ago on Friday 03 December 2021 05:14:03 PM UTC. Dependencies resolved. ======================================================================================== Package Architecture Version Repository Size ======================================================================================== Installing: centos-stream-release noarch 8.6-1.el8 Stream-BaseOS 22 k replacing centos-linux-release.noarch 8.5-1.2111.el8 replacing centos-release-stream.x86_64 8.1-1.1911.0.7.el8 centos-stream-repos noarch 8-3.el8 extras 19 k Removing: centos-linux-repos noarch 8-3.el8 @baseos 26 k Transaction Summary ======================================================================================== Install 2 Packages Remove 1 Package Total download size: 42 k Is this ok [y/N]: y Downloading Packages: (1/2): centos-stream-repos-8-3.el8.noarch.rpm 588 kB/s | 19 kB 00:00 (2/2): centos-stream-release-8.6-1.el8.noarch.rpm 61 kB/s | 22 kB 00:00 ---------------------------------------------------------------------------------------- Total 91 kB/s | 42 kB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: centos-stream-release-8.6-1.el8.noarch 1/1 Installing : centos-stream-release-8.6-1.el8.noarch 1/5 Installing : centos-stream-repos-8-3.el8.noarch 2/5 Obsoleting : centos-release-stream-8.1-1.1911.0.7.el8.x86_64 3/5 Obsoleting : centos-linux-release-8.5-1.2111.el8.noarch 4/5 Erasing : centos-linux-repos-8-3.el8.noarch 5/5 warning: /etc/yum.repos.d/CentOS-Linux-PowerTools.repo saved as /etc/yum.repos.d/CentOS-Linux-PowerTools.repo.rpmsave warning: /etc/yum.repos.d/CentOS-Linux-Plus.repo saved as /etc/yum.repos.d/CentOS-Linux-Plus.repo.rpmsave warning: /etc/yum.repos.d/CentOS-Linux-HighAvailability.repo saved as /etc/yum.repos.d/CentOS-Linux-HighAvailability.repo.rpmsave warning: /etc/yum.repos.d/CentOS-Linux-FastTrack.repo saved as /etc/yum.repos.d/CentOS-Linux-FastTrack.repo.rpmsave warning: /etc/yum.repos.d/CentOS-Linux-Extras.repo saved as /etc/yum.repos.d/CentOS-Linux-Extras.repo.rpmsave warning: /etc/yum.repos.d/CentOS-Linux-Devel.repo saved as /etc/yum.repos.d/CentOS-Linux-Devel.repo.rpmsave warning: /etc/yum.repos.d/CentOS-Linux-ContinuousRelease.repo saved as /etc/yum.repos.d/CentOS-Linux-ContinuousRelease.repo.rpmsave warning: /etc/yum.repos.d/CentOS-Linux-BaseOS.repo saved as /etc/yum.repos.d/CentOS-Linux-BaseOS.repo.rpmsave warning: /etc/yum.repos.d/CentOS-Linux-AppStream.repo saved as /etc/yum.repos.d/CentOS-Linux-AppStream.repo.rpmsave Running scriptlet: centos-linux-repos-8-3.el8.noarch 5/5 Verifying : centos-stream-repos-8-3.el8.noarch 1/5 Verifying : centos-stream-release-8.6-1.el8.noarch 2/5 Verifying : centos-linux-release-8.5-1.2111.el8.noarch 3/5 Verifying : centos-release-stream-8.1-1.1911.0.7.el8.x86_64 4/5 Verifying : centos-linux-repos-8-3.el8.noarch 5/5 Installed: centos-stream-release-8.6-1.el8.noarch centos-stream-repos-8-3.el8.noarch Removed: centos-linux-repos-8-3.el8.noarch Complete!
Finally migrate CentOS 8 installation to CentOS stream
First list repos, run:sudo dnf repolist
Upgrading CentOS 8 to CentOS Stream
We are now close to our target. Next, we need to get packages for CentOS Stream ABI/API. This will upgrade or downgrade packages to match the new ABI/API and break 100% RHEL compatibility due to ABI/API change. I am OK with that. So let us do it:sudo dnf distro-sync
Last metadata expiration check: 0:00:19 ago on Friday 03 December 2021 05:28:32 PM UTC. Dependencies resolved. ======================================================================================== Package Arch Version Repo Size ======================================================================================== Upgrading: NetworkManager x86_64 1:1.36.0-0.1.el8 baseos 2.3 M NetworkManager-libnm x86_64 1:1.36.0-0.1.el8 baseos 1.8 M NetworkManager-team x86_64 1:1.36.0-0.1.el8 baseos 149 k NetworkManager-tui x86_64 1:1.36.0-0.1.el8 baseos 341 k bash x86_64 4.4.20-3.el8 baseos 1.5 M c-ares x86_64 1.13.0-6.el8 baseos 93 k ca-certificates noarch 2021.2.50-82.el8 baseos 390 k cloud-init noarch 21.1-9.el8 appstream 1.0 M cpio x86_64 2.12-11.el8 baseos 266 k cronie x86_64 1.5.2-6.el8 baseos 118 k cronie-anacron x86_64 1.5.2-6.el8 baseos 42 k crypto-policies noarch 20211116-1.gitae470d6.el8 baseos 64 k crypto-policies-scripts noarch 20211116-1.gitae470d6.el8 baseos 83 k device-mapper x86_64 8:1.02.181-1.el8 baseos 377 k device-mapper-libs x86_64 8:1.02.181-1.el8 baseos 409 k dnf noarch 4.7.0-5.el8 baseos 543 k dnf-automatic noarch 4.7.0-5.el8 baseo ..... .. vim-enhanced x86_64 2:8.0.1763-16.el8_5.2 appstream 1.4 M vim-filesystem noarch 2:8.0.1763-16.el8_5.2 appstream 49 k vim-minimal x86_64 2:8.0.1763-16.el8_5.2 baseos 573 k yum noarch 4.7.0-5.el8 baseos 206 k Installing dependencies: glibc-gconv-extra x86_64 2.28-170.el8 baseos 1.4 M Installing weak dependencies: sqlite x86_64 3.26.0-15.el8 baseos 668 k Downgrading: unzip x86_64 6.0-45.el8 baseos 195 k Transaction Summary ======================================================================================== Install 2 Packages Upgrade 86 Packages Downgrade 1 Package Total download size: 95 M Downloading Packages: (1/89): unzip-6.0-45.el8.x86_64.rpm 571 kB/s | 195 kB 00:00 (2/89): sqlite-3.26.0-15.el8.x86_64.rpm 1.4 MB/s | 668 kB 00:00 ..... .. vim-filesystem-2:8.0.1763-16.el8_5.2.noarch vim-minimal-2:8.0.1763-16.el8_5.2.x86_64 yum-4.7.0-5.el8.noarch Downgraded: unzip-6.0-45.el8.x86_64 Installed: glibc-gconv-extra-2.28-170.el8.x86_64 sqlite-3.26.0-15.el8.x86_64 Complete!
Step 5 – Reboot the system
Run:sudo systemctl reboot
Step 6 – Verification
See CentOS stream version for verification:cat /etc/centos-release
Make sure there are no errors. Let us see or view errors log on Linux:sudo tail -f /var/log/messages
sudo grep -i -E 'err|wan|cri' /var/log/messages
sudo grep -i -E 'err|wan|cri' /var/log/nginx/error.log
List open ports on Linux and make sure services such as httpd, mysqld and stuff is running using the systemctl command or netstat command/ss command:sudo ss -tulpn
systemctl status httpd
systemctl status mysqld
A note about 3rd party dnf repos
Some dnf repos may be renamed or disabled to prevent upgrade issues. It would be best if you validated those manually. For example:
# yum repolist
# yum repolist enabled > /root/post.update.dnf.repo.txt
You can compare those two files:# cat /root/post.update.dnf.repo.txt
# cat /root/pre.update.dnf.repo.txt
# diff /root/pre.update.dnf.repo.txt /root/post.update.dnf.repo.txt
Then enable missing repos again.
Video demo
Here is a quick video demo:
Summing up
I am pleasantly surprised by how smoothly the process went. This saved me time. I am also aware that one can take a similar approach to switch to AlmaLinux or RocyLinux, or Oracle Linux by swapping repos. For now, my side project working smoothly on AWS EC2 VM. But, one can use self-hosted or other cloud service providers too. I also deployed a local Rocky Linux VM on my Laptop, where I will containerize my app, so I no longer have to depend on the host OS. That is why I didn’t waste much time with a completely new OS. Do check out the CentOS Stream website for documentation.
Ref: https://www.cyberciti.biz/howto/upgrade-migrate-from-centos-8-to-centos-stream-conversion/