Sometimes you may get the below error while running “rpm -qa” or any other rpm listing command. This error suggests that the RPM db is corrupted and you need to clean it up.

rpmdb: PANIC: fatal region error detected; run recovery
error: db4 error(-30977) from dbenv->open: DB_RUNRECOVERY

Here are the steps to do it.

  1. Remove the rpm db lock information files

    rm -f /var/lib/rpm/__db*

  2. Run the rpm rebuild database command . The rpm –rebuilddb option will rebuild the database indices from the installed RPM package headers. This process will take a while to complete. Once it is completed, the rpm -qa and other rpm listing commands will work.

    rpm –rebuilddb