Google
 

«           »

Recovering a Corrupted RPM Database

Posted November 28, 2004 – 8:37 pm by Yakov Shafranovich in Linux, Programming

One of the more fun things to do for Linux sysadmins is dealing with corrupted RPM databases. RPM or “Redhat Package Manager” was invented by Redhat to allow for easier management of installed programs and dependicies on Linux systems.

In my specific case, one of our servers running Fedora Core 2 somehow got its RPM database corrupted. The recommended remedy is running “rpm -vv –rebuilddb” to rebuild the RPM database from the sources. In our case it was so bad, that everything was corrupted. Luckily, Redhat systems run a cron job daily to record the list of all RPM packages in the system and place that in the “/var/log/rpmpckgs” file. So the solution was as follows:

1. Backup the /var/lib/rpm directory (tar -cf somefile /var/lib/rpm/).
2. Erase the RPM files (rm /var/lib/rpm/* -f).
3. Re-init the RPM database (rpm -vv –initdb).
4. Use a script written by Michael Fratoni to parse the package list and rebuild the DB.

The two problems that I had is figuring out that the “/var/lib/rpm” directory needed to be emptied AND that we didn’t have any RPM files on disk (which the script required). Some more patching of the script to download the files first via “wget” helped. The result – an hour of command line work and one recovered RPM database.

Tags: ,

Permalink | Trackback URL | This post has

Sorry, comments for this entry are closed at this time.