[CentOS] Recover rpm DB corrupted by disk failure?

Mon Feb 23 16:59:15 UTC 2009
Bill Campbell <centos at celestial.com>

On Mon, Feb 23, 2009, Bart Schaefer wrote:
>Over the weekend my workstation (still on CentOS 3) started showing
>SMART errors, so we shut it down and moved everything onto a new
>drive.  On reboot, the RPM database reports as corrupted and "rpm
>--rebuilddb" segmentation faults.
>
>Is there any reasonable way to recover from this, short of a complete
>reinstall?  The machine is otherwise up though it's quite likely some
>files have been lost.

You may be able to get things going again with the bdb recover
script, /usr/lib/rpm/rpmdb_recover.  I think this should be a
berkeley DB recovery routine that is specific to the version
being used by rpm.  I have recovered the OpenPKG rpm database
using this technique using the standard bdb db_recover program.

If I am not mistaken, the appropriate command would be:

/usr/lib/rpm/rpmdb_recover -h /var/lib/rpm

Bill
-- 
INTERNET:   bill at celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
Voice:          (206) 236-1676  Mercer Island, WA 98040-0820
Fax:            (206) 232-9186

Cutting the space budget really restores my faith in humanity.  It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation.  -- Johnny Hart