[CentOS] Recover rpm DB corrupted by disk failure?

Mon Feb 23 20:06:09 UTC 2009
Bart Schaefer <barton.schaefer at gmail.com>

On Mon, Feb 23, 2009 at 10:13 AM, Bill Campbell <centos at celestial.com> wrote:
>
> That machine has /usr/bin/db_recover as part of the package
> db4-utils-4.2.52-7.1 which may work.

# db_recover -h /var/lib/rpm
db_recover: unable to join the environment

rpmdb_verify still reports DB_VERIFY_BAD afterwards.  In fact several
of the files are trashed, not just Packages:

# /usr/lib/rpm/rpmdb_verify Basenames
db_verify: Page 2596: overflow page of invalid type 2
db_verify: Page 2466: hash page has bad prev_pgno
db_verify: Page 0: non-invalid page 2405 on free list
db_verify: DB->verify: Basenames: DB_VERIFY_BAD: Database verification failed
# /usr/lib/rpm/rpmdb_verify Filemd5s
db_verify: Page 1328: hash page has bad prev_pgno
db_verify: Page 0: non-invalid page 1330 on free list
db_verify: DB->verify: Filemd5s: DB_VERIFY_BAD: Database verification failed
# /usr/lib/rpm/rpmdb_verify Name
db_verify: Page 10: hash page has bad prev_pgno
db_verify: DB->verify: Name: DB_VERIFY_BAD: Database verification failed
 /usr/lib/rpm/rpmdb_verify Packages
db_verify: Page 9537: overflow page of invalid type 2
(some hundreds of other errors)
db_verify: Page 0: non-invalid page 12437 on free list
db_verify: DB->verify: Packages: DB_VERIFY_BAD: Database verification failed
# /usr/lib/rpm/rpmdb_verify Requirename
db_verify: Page 48: overflow page of invalid type 2
db_verify: Page 53: overflow page of invalid type 2
db_verify: Page 52: hash page has bad prev_pgno
db_verify: Page 55: overflow page of invalid type 2
db_verify: Page 54: hash page has bad prev_pgno
db_verify: Page 50: hash page has bad prev_pgno
db_verify: Page 59: hash page has bad prev_pgno
db_verify: Page 94: hash page has bad prev_pgno
db_verify: Page 0: non-invalid page 96 on free list
db_verify: DB->verify: Requirename: DB_VERIFY_BAD: Database verification failed
# /usr/lib/rpm/rpmdb_verify Sha1header
db_verify: Page 12: hash page has bad prev_pgno
db_verify: DB->verify: Sha1header: DB_VERIFY_BAD: Database verification failed