How to do recovery rpm database?

Asked By 100 points N/A Posted on -

Please I need help on how to do recovery rpm database that got corrupted for no reason at all.

Last week it was running smoothly then suddenly this morning it went nuts.

Answered By 0 points N/A #190517

How to do recovery rpm database?


Hey Martin,

Follow the steps below to recover your rpm database –

First, you would need to backup your existing database (just in case); this is located in /var/lib/rpm and depending on your distribution the content of the folder might look like this:/var/lib/rpm-rw-r–r– 1 rpm rpm 5464064 Feb 9 04:17 Basenames-rw-r–r– 1 rpm rpm 12288 Feb 3 05:03 Conflictname-rw-r–r– 1 root root 0 Aug 25 02:48 __db.000-rw-r–r– 1 root root 24576 Aug 14 04:02 __db.001-rw-r–r– 1 root root 1318912 Aug 14 04:02 __db.002-rw-r–r– 1 root root 450560 Aug 14 04:02 __db.003-rw-r–r– 1 rpm rpm 1982464 Feb 9 04:17 Dirnames-rw-r–r– 1 rpm rpm 5259264 Feb 9 04:17 Filemd5s-rw-r–r– 1 rpm rpm 24576 Feb 9 04:17 Group-rw-r–r– 1 rpm rpm 28672 Feb 9 04:17 Installtid-rw-r–r– 1 rpm rpm 45056 Feb 9 04:17 Name-rw-r–r– 1 rpm rpm 31707136 Feb 9 04:17 Packages-rw-r–r– 1 rpm rpm 339968 Feb 9 04:17 Providename-rw-r–r– 1 rpm rpm 106496 Feb 9 04:17 Provideversion-rw-r–r– 1 rpm rpm 12288 Dec 2 08:45 Pubkeys-rw-r–r– 1 rpm rpm 253952 Feb 9 04:17 Requirename-rw-r–r– 1 rpm rpm 167936 Feb 9 04:17 Requireversion-rw-r–r– 1 rpm rpm 86016 Feb 9 04:17 Sha1header-rw-r–r– 1 rpm rpm 49152 Feb 9 04:17 Sigmd5-rw-r–r– 1 rpm rpm 12288 Jan 15 21:09 Triggername

Then just backup all the /var/lib/rpm folder to its original state:cd /var/lib tar czvf rpmdb.tar.gz rpm

Finally, rebuild the rpm database:cd /var/lib/rpm rm -f __db* rpm –rebuilddb -vv

After this, your rpm commands should be working again.


Answered By 560660 points N/A #190518

How to do recovery rpm database?


If your RPM database got suddenly corrupted for no reason, here’s how you can fix it. Take note: it is not always possible to fix errors in an RPM database especially if you don’t have a backup of your database. But sometimes it is possible. You should have rpmdb tools installed.

First, bring your system to single-user mode to prevent further damage to the database and also this makes the backup or restore process easy. Next, you need to remove “/var/lib/rpm/__db*” files to prevent stale locks. To do this, do the following:

After this, rebuild the RPM database:

See if you are still getting any errors after this. In case this doesn’t fix the problem and you are still getting errors, try the following commands if they’ll work:

For further help on repairing RPM database, visit RPM DB Recovery on RHEL 3.

Login/Register to Answer

Related Questions