Dnf update fails with hanging during the update

  1. Make sure that the storage and RAM are fine and sufficient and the filesystem is consistent, otherwise you may end up in an endless loop of errors.

  2. Switch SELinux to permissive mode or temporarily disable it to avoid related errors.

  3. Perform distro-sync and remove duplicates if any, assuming you are using DNF5:

sudo dnf distro-sync --refresh
sudo dnf reinstall $(dnf rq --duplicates --latest-limit=1 --qf="%{name}\n")

Make sure the database points to the latest release, otherwise explicitly specify the release version until the issue is resolved:

sudo dnf --dump-variables
sudo dnf ... --releasever=41

If necessary, ignore protected packages:

sudo dnf ... --setopt=protected_packages=
sudo sed -i -e 's/^/#/' /etc/dnf/protected.d/*

Any blocking package can be manually removed, ignoring its dependencies:

sudo rpm -e --justdb --nodeps package_name
  1. Check for problems in the RPM database, rebuild it, verify integrity for all installed packages and reinstall corrupted ones if any:
sudo dnf check
sudo rpm --rebuilddb
sudo rpm -V -a
  1. Enable SELinux and fix labels for the entire filesystem.
2 Likes