Skip to content

Instantly share code, notes, and snippets.

@gilbertoalbino
Forked from yodermk/centos8-9.sh
Created July 13, 2022 20:24
Show Gist options
  • Save gilbertoalbino/dfe9fef3e9deeb3d3792d49f9fa6ac54 to your computer and use it in GitHub Desktop.
Save gilbertoalbino/dfe9fef3e9deeb3d3792d49f9fa6ac54 to your computer and use it in GitHub Desktop.
Commands to live-upgrade CentOS Streams 8 -> 9
# The general procedure here is adapted from the 7->8 guide here. https://www.tecmint.com/upgrade-centos-7-to-centos-8/
#
# It is a curated list of my bash history. I entered other commands so hopefully I got the right ones here.
yum upgrade
reboot
dnf install epel-release
dnf install rpmconf
dnf install yum-utils
rpmconf -a # answer "n" to both things
package-cleanup --leaves
package-cleanup --orphans
dnf install http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-stream-repos-9.0-9.el9.noarch.rpm http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-stream-release-9.0-9.el9.noarch.rpm http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-gpg-keys-9.0-9.el9.noarch.rpm
curl -O https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
curl -O https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm
rpm -Uvh *.rpm
yum update
dnf clean all
rpm -e `rpm -q kernel`
dnf -y --releasever=9 --allowerasing --setopt=deltarpm=false distro-sync
dnf clean all
reboot
rm -f /var/lib/rpm/__db*
rpm --rebuilddb
dnf -y groupupdate "Core" "Minimal Install"
@odmro
Copy link

odmro commented Apr 20, 2024

As of 2024 420:

dnf upgrade
reboot
dnf install epel-release rpmconf yum-utils
dnf install http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-stream-repos-9.0-24.el9.noarch.rpm http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-stream-release-9.0-24.el9.noarch.rpm http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-gpg-keys-9.0-24.el9.noarch.rpm
curl -O https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
curl -O https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm
rpm -Uvh .rpm
rpm -e rpm -q kernel
dnf -y --releasever=9 --allowerasing --setopt=deltarpm=false distro-sync
dnf remove subscription-manager
rpm --rebuilddb
dnf clean all
dnf update
rm -f /var/lib/rpm/__db

dnf -y groupupdate "Core" "Minimal Install"

@koelle25
Copy link

koelle25 commented Jun 5, 2024

To correctly format @odmro's reply:

# dnf upgrade
# reboot
# dnf install epel-release rpmconf yum-utils
# dnf install http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-stream-repos-9.0-24.el9.noarch.rpm http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-stream-release-9.0-24.el9.noarch.rpm http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-gpg-keys-9.0-24.el9.noarch.rpm
# curl -O https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
# curl -O https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm
# rpm -Uvh *.rpm
# rpm -e `rpm -q kernel`
# dnf -y --releasever=9 --allowerasing --setopt=deltarpm=false distro-sync
# dnf remove subscription-manager
# rpm --rebuilddb
# dnf clean all
# dnf update
# rm -f /var/lib/rpm/__db*
# dnf -y groupupdate "Core" "Minimal Install"

Besides this, at the step dnf remove subscription-manager I got:

RPM: warning: Found bdb_ro Packages database while attempting sqlite backend: using bdb_ro backend.
RPM: error: cannot open Packages index using bdb_ro - Operation not permitted (1)
RPM: error: cannot open Packages database in /var/lib/rpm
Error: Could not run transaction.

A quick web search led me to this Bugzilla issue: https://bugzilla.redhat.com/show_bug.cgi?id=1960991#c2
TLDR: Restoring SELinux permissions and then rebuilding the RPM-DB solves it:

# restorecon -Rv /var/lib/rpm
# rpmdb --rebuilddb
warning: Converting database from bdb_ro to sqlite backend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment