Updated: 3 November 2026 · Applies to: yum and dnf, on AlmaLinux, Rocky Linux and RHEL

"Database disk image is malformed" means yum's (or dnf's) local metadata cache is corrupted, usually from an update or install that was interrupted partway through. Clear the cache and rebuild it to fix it.

On current AlmaLinux, Rocky Linux and RHEL releases, yum is simply an alias for dnf; every command below works identically with either name.

Step 1: clear the package manager's cache

dnf clean dbcache

If that alone does not resolve it, clear everything and rebuild the metadata cache from scratch:

dnf clean all
dnf makecache

Step 2: rebuild the underlying RPM database, carefully

If the error persists, the corruption is more likely in the RPM database itself rather than just dnf's own cache. Before touching it: on current AlmaLinux and RHEL releases (EL9 and EL10), a damaged RPM database has been seen to make rpmdb --rebuilddb report success while actually discarding most of the package list, so back up the database directory first, every time, no exceptions:

cp -a /var/lib/rpm /var/lib/rpm.bak-$(date +%Y%m%d)

Note how many packages are currently registered, so you have something to compare against afterward:

rpm -qa | wc -l

Now rebuild:

mv /var/lib/rpm/__db* /tmp/
rpm --rebuilddb

Immediately check the package count again:

rpm -qa | wc -l

If that number dropped significantly from what you noted before, the rebuild went wrong; restore the backup instead of continuing:

rm -rf /var/lib/rpm
mv /var/lib/rpm.bak-$(date +%Y%m%d) /var/lib/rpm

Step 3: confirm it is fixed

dnf update

If the update runs normally instead of throwing the same error, the database is repaired.

Finding which repository a package came from

Older yum versions kept this kind of supplementary per-package metadata in a separate flat-file store, read with a yumdb command. That command has been removed from current yum-utils on AlmaLinux, Rocky Linux and RHEL 10 (confirmed: installing yum-utils on EL10 no longer provides a yumdb binary at all). On a current system, repoquery answers the same question instead:

dnf install -y yum-utils
dnf repoquery -q --installed --qf "%{name}: %{from_repo}" httpd

This prints the package name and the repository it was installed from, which is the most commonly needed piece of that old yumdb information. If you are on an older EL7 or EL8 system where yumdb is still present, the original commands (yumdb get from_repo httpd, yumdb set note "..." httpd, yumdb info httpd) still work there.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket