Reinstalling an RHEL-like in-place

Dumb Linux trick:

Suspicious of damaged system files on an RHEL-like (rocky, alma, centos, probably fedora, whatever) system?

Once you get it unfucked enough to use the package manager (dealing with filesystem problems, hand-re-installing the rpms required to make dnf work, etc.) , systematically reinstall all installed packages!

As root do a:
rpm -qa --queryformat "%{NAME}\n" > installed.txt
dnf reinstall $(<installed.txt)

and settle in for a long operation.

I’ve done it on Arch boxes where it is written as something like pacman -Qqn | pacman -S -, but hadn’t tried it with dnf until I had a Rocky 8 box wedge during a dnf upgrade yesterday and wipe out large pieces of the system, then cause some damage to the (annoying default XFS on LVM) root when a reboot failed. It seems to have worked.

This entry was posted in Computers, General. Bookmark the permalink.

Leave a Reply

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