Labels

Wednesday, 23 March 2011

Rebuild RPM database in Linux

At times you may find that when you do rpm -qa or try to run a query against rpm it hangs and will never come out .The situation is a pointer to your rpm database being corrupt .

To fix the issue do below

# killall -9 rpm
# ls -ltr

rpm -vv --rebuilddb

That is two underscore "_" characters before the "*" in the above command. You should be prompted if you want to delete the following files:

/var/lib/rpm/__db.001
/var/lib/rpm/__db.002
/var/lib/rpm/__db.003

Once the rebuild complete you will be able to run your commands succesfully .

1 comment:

  1. I got below error while doing a rebuild
    rpm -vv --rebuilddb
    D: rebuilding database /var/lib/rpm into /var/lib/rpmrebuilddb.20973
    D: creating directory: /var/lib/rpmrebuilddb.20973
    D: opening old database
    D: opening database mode 0x0 in /var/lib/rpm
    failed to open /var/lib/rpm/packages.rpm: No such file or directory

    ReplyDelete