Thursday, July 26, 2012
2:56 PM

Rebuilding corrupted RPM database

One of our client reported that he is getting an error and RPM database is corrupted. He is using Red Hat Linux

Sometime it is possible to fix RPM database errors. I am surprised that many admins do not make back up of RPM DB (/var/lib/rpm).

Anyways if you ever messed up with RPM database, here is a quick guide to fix it (you must have rpmdb tools installed):

Take system to single user mode to avoid further damage and to make backup/restore process easy:

# init 1
Method # 1

Remove /var/lib/rpm/__db* files to avoid stale locks:
# cd /var/lib
# rm __db*

Rebuild RPM database:
# rpm --rebuilddb
# rpmdb_verify Packages
Method # 2

If you are still getting errors, then try your luck with following commands:

# mv Packages Packages-BAKUP
# db_dump Packages-BAKUP | db_load Packages
# rpm -qa
# rpm --rebuilddb

0 comments:

Post a Comment