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

Error: rpmdb open failed

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

How can I solve this?


This is how I fixed my problem.

You may fix this by cleaning out rpm database. But first, in order to minimize the risk, make sure you create 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/

The try this to fix this problem:

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

And finally verify that error has gone with the following yum command

# yum update
| improve this answer | |
  • 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
  • 10
    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
  • 4
    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*
| improve this answer | |
  • 3
    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
| improve this answer | |

All I had to do was to delete the two file with the ".lock" extension, and the three files that started with "__db".

# rm /var/lib/rpm/.dbenv.lock
# rm /var/lib/rpm/.rpm.lock
# rm /var/lib/rpm/__db*

After that, yum update worked.

| improve this answer | |

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