Recovering from a corrupted RPM database
Although everything is done to ensure that your RPM databases are intact, your RPM database may become corrupt and unuseable. This happens mainly if the filesystem on which the rpm db
resides is suddenly inaccessible (full, read-only, reboot, or so on).
This recipe will show you the two ways in which you can attempt to restore your RPM database.
Getting ready
Verify that your system is backed up in some way.
How to do it…
We'll start with the easiest option and the one with the highest success rate in these steps:
Start by creating a backup of your corrupt
rpm db
, as follows:~]# cd; tar zcvf rpm-db.tar.gz /var/lib/rpm/*
Remove stale lock files if they exist through the following command:
~]# rm -f /var/lib/rpm/__db*
Now, verify the integrity of the
Packages
database via the following:~]# /usr/lib/rpm/rpmdb_verify /var/lib/rpm/Packages; echo $?
If the previous step prints
0
, proceed to Step 7.Rename the
Packages
file (don't delete it, we'll need it!),...