📖 ~1 min read
Table of contents
Symptom & Impact
rpm or dnf returns ‘rpmdb open failed’ after an unclean shutdown.
Environment & Reproduction
Triggered by power loss or kill -9 of a dnf transaction.
rpm --version
ls -l /var/lib/rpm
Root Cause Analysis
Berkeley DB pages or sqlite WAL in /var/lib/rpm are inconsistent.
Quick Triage
Stop package operations and snapshot the rpm DB.
tar -czf /root/rpmdb.$(date +%F).tgz /var/lib/rpm
Step-by-Step Diagnosis
Run rpm consistency checks to confirm corruption.
rpm -qa >/dev/null
rpm --rebuilddb -v

Solution – Primary Fix
Rebuild the rpm database from a clean state.
Still having issues? Our IT Solutions & Services team can diagnose and resolve this for you. Get in touch for a free consultation.
rm -f /var/lib/rpm/__db*
rpm --rebuilddb
dnf -y check

Solution – Alternative Approaches
Restore from a recent backup if rebuild fails.
tar -xzf /root/rpmdb.last-good.tgz -C /
Verification & Acceptance Criteria
rpm -qa returns full package list without errors.
rpm -qa | wc -l
dnf history list | head
Rollback Plan
Re-apply the snapshot tarball if rebuild breaks queries.
tar -xzf /root/rpmdb.$(date +%F).tgz -C /
Prevention & Hardening
Avoid forced kills of dnf and keep daily rpmdb backups.
(crontab -l; echo '5 2 * * * tar -czf /var/backups/rpmdb.$(date +%F).tgz /var/lib/rpm') | crontab -
Related Errors & Cross-Refs
rpmdb lock errors, db_recover failures.
Related tutorial: View the step-by-step tutorial for centos-stream-10.
View all centos-stream-10 tutorials on the Tutorials Hub →
Browse all common problems & solutions on the Tutorials Hub.
References & Further Reading
RPM database administration, recovery notes.
Need Expert Help?
If you cannot resolve this yourself, our team offers hands-on Server Management, Managed IT Services, and flexible Support Plans. Contact us today — we respond within one business day.