Skip to content

Instantly share code, notes, and snippets.

@grizz
Last active November 23, 2023 15:14
Show Gist options
  • Save grizz/e3668652c0f0b121118ce37d29b06dbf to your computer and use it in GitHub Desktop.
Save grizz/e3668652c0f0b121118ce37d29b06dbf to your computer and use it in GitHub Desktop.
Convert CentOS Stream to AlmaLinux
# swap back to stream repos
# dnf swap centos-{stream,linux}-repos -- only works if the centos-linux-repos package is cached
dnf install --allowerasing https://mirror.rackspace.com/centos-vault/8.5.2111/BaseOS/x86_64/os/Packages/centos-linux-repos-8-3.el8.noarch.rpm
# doesn't work, need to manually flip after update
# dnf swap centos-{stream,linux}-release
# update to centos-vault repos
sudo sed -i -e '/mirrorlist=http:\/\/mirrorlist.centos.org\/?release=$releasever&arch=$basearch&repo=/ s/^#*/#/' -e '/baseurl=http:\/\/mirror.centos.org\/$contentdir\/$releasever\// s/^#*/#/' -e '/^\[baseos\]/a baseurl=https://mirror.rackspace.com/centos-vault/8.5.2111/BaseOS/$basearch/os' /etc/yum.repos.d/CentOS-Linux-BaseOS.repo
sudo sed -i -e '/mirrorlist=http:\/\/mirrorlist.centos.org\/?release=$releasever&arch=$basearch&repo=/ s/^#*/#/' -e '/baseurl=http:\/\/mirror.centos.org\/$contentdir\/$releasever\// s/^#*/#/' -e '/^\[appstream\]/a baseurl=https://mirror.rackspace.com/centos-vault/8.5.2111/AppStream/$basearch/os' /etc/yum.repos.d/CentOS-Linux-AppStream.repo
sudo sed -i -e '/mirrorlist=http:\/\/mirrorlist.centos.org\/?release=$releasever&arch=$basearch&repo=/ s/^#*/#/' -e '/baseurl=http:\/\/mirror.centos.org\/$contentdir\/$releasever\// s/^#*/#/' -e '/^\[cr\]/a baseurl=https://mirror.rackspace.com/centos-vault/8.5.2111/ContinuousRelease/$basearch/os' /etc/yum.repos.d/CentOS-Linux-ContinuousRelease.repo
sudo sed -i -e '/mirrorlist=http:\/\/mirrorlist.centos.org\/?release=$releasever&arch=$basearch&repo=/ s/^#*/#/' -e '/baseurl=http:\/\/mirror.centos.org\/$contentdir\/$releasever\// s/^#*/#/' -e '/^\[devel\]/a baseurl=https://mirror.rackspace.com/centos-vault/8.5.2111/Devel/$basearch/os' /etc/yum.repos.d/CentOS-Linux-Devel.repo
sudo sed -i -e '/mirrorlist=http:\/\/mirrorlist.centos.org\/?release=$releasever&arch=$basearch&repo=/ s/^#*/#/' -e '/baseurl=http:\/\/mirror.centos.org\/$contentdir\/$releasever\// s/^#*/#/' -e '/^\[extras\]/a baseurl=https://mirror.rackspace.com/centos-vault/8.5.2111/extras/$basearch/os' /etc/yum.repos.d/CentOS-Linux-Extras.repo
sudo sed -i -e '/mirrorlist=http:\/\/mirrorlist.centos.org\/?release=$releasever&arch=$basearch&repo=/ s/^#*/#/' -e '/baseurl=http:\/\/mirror.centos.org\/$contentdir\/$releasever\// s/^#*/#/' -e '/^\[fasttrack\]/a baseurl=https://mirror.rackspace.com/centos-vault/8.5.2111/fasttrack/$basearch/os' /etc/yum.repos.d/CentOS-Linux-FastTrack.repo
sudo sed -i -e '/mirrorlist=http:\/\/mirrorlist.centos.org\/?release=$releasever&arch=$basearch&repo=/ s/^#*/#/' -e '/baseurl=http:\/\/mirror.centos.org\/$contentdir\/$releasever\// s/^#*/#/' -e '/^\[ha\]/a baseurl=https://mirror.rackspace.com/centos-vault/8.5.2111/HighAvailability/$basearch/os' /etc/yum.repos.d/CentOS-Linux-HighAvailability.repo
sudo sed -i -e '/mirrorlist=http:\/\/mirrorlist.centos.org\/?release=$releasever&arch=$basearch&repo=/ s/^#*/#/' -e '/baseurl=http:\/\/mirror.centos.org\/$contentdir\/$releasever\// s/^#*/#/' -e '/^\[plus\]/a baseurl=https://mirror.rackspace.com/centos-vault/8.5.2111/centosplus/$basearch/os' /etc/yum.repos.d/CentOS-Linux-Plus.repo
sudo sed -i -e '/mirrorlist=http:\/\/mirrorlist.centos.org\/?release=$releasever&arch=$basearch&repo=/ s/^#*/#/' -e '/baseurl=http:\/\/mirror.centos.org\/$contentdir\/$releasever\// s/^#*/#/' -e '/^\[powertools\]/a baseurl=https://mirror.rackspace.com/centos-vault/8.5.2111/PowerTools/$basearch/os' /etc/yum.repos.d/CentOS-Linux-PowerTools.repo
# remove packages not in base RHEL
yum remove glibc-gconv-extra NetworkManager-initscripts-updown
# sync to new repo files and reboot
dnf distro-sync
reboot
# switch from Stream release to Linux release
rpm -e --nodeps centos-stream-release
yum install centos-linux-release --releasever=8
# continue on with https://github.com/AlmaLinux/almalinux-deploy
./almalinux-deploy.sh
@itsnotyoutoday
Copy link

Badass, cool that this was posted just shortly before I was trying to accomplish this!

@itsnotyoutoday
Copy link

One more thing I'd add. I was getting this error: Unable to detect release version (use '--releasever' to specify release version)

Fixed by doing adding this your yum install centos-linux-release
yum install centos-linux-release --releasever=8

@grizz
Copy link
Author

grizz commented Mar 27, 2022

Thanks @itsnotyoutoday, updated -- I was lazy and just ignored it since it was a warning. :)

@grizz
Copy link
Author

grizz commented Apr 7, 2022

I've also ran into needing to remove and install qemu, so

yum remove qemu-kvm\*

If centos-linux-repos is not found, this also works:

dnf install --allowerasing https://mirror.rackspace.com/centos-vault/8.5.2111/BaseOS/x86_64/os/Packages/centos-linux-repos-8-3.el8.noarch.rpm

@TCMcG008
Copy link

Thank you, grizz, for creating this; certainly useful. I'm customizing some things on it for my uses, and I had a question. On line 4 you commented that this step may need to be run after the update. Where in this version would you recommend performing that flip?
Thank you.

@grizz
Copy link
Author

grizz commented Apr 19, 2022

@TCMcG008 Yeah, it's done on lines 25-27 -- I just left that comment in there because I forgot it didn't work and tried it twice. :)

@TCMcG008
Copy link

TCMcG008 commented Apr 20, 2022 via email

@ghsolutions
Copy link

worked for me on local VMware instance

@grizz
Copy link
Author

grizz commented Apr 21, 2022

@TCMcG008 sure, thanks

@josemaX
Copy link

josemaX commented Apr 22, 2022

Worked for me on a Proxmox VM running Icinga over Stream 8. Everything running at first try!

Thanks!!!

@TCMcG008
Copy link

TCMcG008 commented Jun 8, 2022

Been meaning to update you here. Based on your code I've written this version:
https://github.com/TCMcG008/stream-rollback
It's got a bit more stuff due to some errors and hurdles I encountered along the way. IDK if I'll be doing too much more to update it as this is mainly a bridge to get everyone safely away from Stream.

Thank you again, Grizz!
~TCMcG

@grizz
Copy link
Author

grizz commented Jun 8, 2022

Awesome, will use that next time I need to do do it. Cheers!

@ch604
Copy link

ch604 commented Sep 16, 2022

this went pretty well for me up until reboot, its likely that some users will need to rebuild grub per @TCMcG008 's script:

/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg

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