π ~1 min read
Table of contents
Symptom & Impact
rpm and dnf commands fail, blocking all installs, updates, and security remediation.
Environment & Reproduction
Common after abrupt power loss during package transaction.
rpm -qa | head ; sudo dnf check
Root Cause Analysis
Berkeley DB or sqlite metadata corruption leaves package index unreadable or inconsistent.
Quick Triage
Capture exact rpmdb errors and check filesystem integrity before rebuild.
sudo journalctl -n 80 | grep -Ei 'rpm|dnf|db' ; sudo rpm --verify rpm
Step-by-Step Diagnosis
Back up rpm database files and validate lock state.
sudo ls -la /var/lib/rpm ; sudo fuser -v /var/lib/rpm/* ; sudo cp -a /var/lib/rpm /var/lib/rpm.backup.$(date +%F)

Solution β Primary Fix
Rebuild rpm database and refresh dnf metadata cleanly.
Still having issues? Our IT Solutions & Services team can diagnose and resolve this for you. Get in touch for a free consultation.
sudo rm -f /var/lib/rpm/__db* ; sudo rpm --rebuilddb ; sudo dnf clean all ; sudo dnf makecache

Solution β Alternative Approaches
Restore rpmdb from recent backup snapshot if rebuild still fails.
Verification & Acceptance Criteria
rpm queries and dnf transactions complete without db error messages.
rpm -qa | wc -l ; sudo dnf check ; sudo dnf repolist
Rollback Plan
Return to backed-up /var/lib/rpm contents if rebuilt index is inconsistent.
sudo rm -rf /var/lib/rpm ; sudo cp -a /var/lib/rpm.backup. /var/lib/rpm
Prevention & Hardening
Use reliable power and avoid forced reboot during dnf/rpm operations.
Related Errors & Cross-Refs
Often occurs alongside dnf lock conflicts and interrupted transactions.
Related tutorial: View the step-by-step tutorial for rhel-10.
View all rhel-10 tutorials on the Tutorials Hub β
Browse all common problems & solutions on the Tutorials Hub.
References & Further Reading
Red Hat KB articles on rpmdb recovery and package database hygiene.
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.