Updated: 28 September 2026 · Applies to: RPM 4.16 (AlmaLinux, Rocky Linux, RHEL 9) and 4.19 (version 10), SQLite package database

The RPM database records every installed package. If it is damaged, for example by a full disk or a crash during an update, rpm and dnf fail with errors such as "rpmdb open failed", "database disk image is malformed" or "error: cannot open Packages database". On CentOS 7 and older releases the database used Berkeley DB files (__db.001 and similar). On AlmaLinux, Rocky Linux and RHEL 9 and 10 it is a single SQLite file, rpmdb.sqlite, and the repair is simpler. We tested the rebuild on AlmaLinux 9.

Where the database is

  • Version 9: /var/lib/rpm/rpmdb.sqlite
  • Version 10: /usr/lib/sysimage/rpm/rpmdb.sqlite; /var/lib/rpm is a link to that folder.

rpm -E %_dbpath shows the path on any system.

Steps

  1. Make sure no rpm or dnf process is running: pgrep -a 'rpm|dnf|yum|packagekit'. Wait for them, or stop PackageKit with systemctl stop packagekit.
  2. Check the disk: df -h /var /usr. A full disk is a common cause; free space first.
  3. Back up the database folder:
    cp -a "$(rpm -E %_dbpath)" /root/rpmdb-backup-$(date +%F)
  4. Check the database:
    rpmdb --verifydb
    No output means no problems were found.
  5. Rebuild it from the package headers it contains:
    rpmdb --rebuilddb
  6. Test that packages are listed again and dnf works:
    rpm -qa | wc -l
    dnf check
    dnf makecache

If the rebuild fails

  • "failed to replace old database with new database": the rebuilt copy is in a folder named rpmrebuilddb.NNNN next to the database. This happens when the database folder cannot be replaced, for example in some containers. Follow the message's advice and copy the files from that folder over the old ones, with a backup in place.
  • Packages are missing after the rebuild: the damaged records could not be recovered. Reinstall the affected packages with dnf reinstall; rpm -Va helps to find files that no package claims.
  • Nothing helps: restore the database folder from a system backup taken before the problem.

Official documentation: RPM documentation and rpmdb manual page.

Ucartz services for this topic

Was this answer helpful? 0 Users Found This Useful (0 Votes)