I'm trying to run yum update and I'm running this error:

rpmdb: PANIC: fatal region error detected; run recovery
error: db3 error(-30974) from dbenv->open: DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db3 - (-30974)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:

Error: rpmdb open failed

I checked page like this one but running yum clean all runs the same error.

How can I solve this?

migrated from serverfault.com Apr 26 '15 at 12:51

This question came from our site for system and network administrators.

up vote 77 down vote accepted

This is how I fixed my problem.

This is quite the messy situation. You may fix this by cleaning out rpm database. To minimize risk, make a backup of files in /var/lib/rpm/ using cp command:

mkdir /root/backups.rpm.mm_dd_yyyy/
cp -avr /var/lib/rpm/ /root/backups.rpm.mm_dd_yyyy/

To fix this problem, try:

# rm -f /var/lib/rpm/__db*
# db_verify /var/lib/rpm/Packages
# rpm --rebuilddb
# yum clean all

Verify that error has gone with the following yum command

# yum update
  • This solution seems to work with dnf instead of yum as well. – unhammer Jan 18 '16 at 14:30
  • I get "unfinished transactions remaining.." after doing all this, and the broken packages that created the problem continues to block any future installations. For that matter, why would the end-user need to see/do any of this? If the yum-db has an issue, it should clean/fix itself automatically - with at most a y/n prompt which an os-tinkerer might want to opt out of. Found the fix for my case - do the above, then do "yum-complete-transaction --cleanup-only" – JosephK Mar 13 '16 at 10:05
  • 8
    Why not just cd /var/lib/rpm; db_recover ? In most cases that's much less of a nuclear option. – Craig Ringer Feb 24 '17 at 8:06
  • 3
    I find sudo rpm --rebuilddb alone solves my case. Nevertheless always backup /var/lib/rpm for safe. – alick Jun 12 '17 at 21:44
  • For those who still see the killed message on yum install, just restart your server. Yes, it sucks to restart to get something basic like this working, but that was the only thing that worked for me. – Nirmal Nov 15 '17 at 6:44

Thanks Alex, your answer worked for me apart from one slight change I had to make.

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

returned errors

rm: cannot remove `/var/lib/rpm/__db.001': Is a directory
rm: cannot remove `/var/lib/rpm/__db.002': Is a directory
rm: cannot remove `/var/lib/rpm/__db.004': Is a directory

so I had to recurse with

rm -rf /var/lib/rpm/__db*
  • 2
    Those should not be directories. If you see that, then you may want to run fsck on your partition to ensure you don't have file corruption. – docwhat Jul 15 '16 at 15:28

I tried the above one it did'nt work

below works fine

# cd /var/lib
# tar -zcvf /var/preserve/rpmdb-$(date +%Y-%m-%d_%H-%M-%S).tar.gz rpm

Note: This tar backup can be used if the attempt to recover the RPM database has issues.

Verify integrity of the Packages file:

# cd /var/lib/rpm
# rm -f __db*      # to avoid stale locks
# /usr/lib/rpm/rpmdb_verify Packages

# mv Packages Packages.orig
# /usr/lib/rpm/rpmdb_dump Packages.orig | /usr/lib/rpm/rpmdb_load Packages


# rpm -vv --rebuilddb

Once again verify RPM database:

# cd /var/lib/rpm
# /usr/lib/rpm/rpmdb_verify Packages

protected by Community Dec 14 '16 at 3:39

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.