Sometime ago I managed to erase the /var/lib/rpm folder which basically contains information about all the rpms in the System

The problem posed is that I cannot query nor Upgrade using the yum

I did the steps mentioned like rpm --rebuild and ll that but it did not help

Its my pure curiosity to know of a method by which we can restore the database of the installed rpm's

I say curiosity, because the server runs fine without it also !!!

Hope no one does this anytime ... I lost many days sleep for this

Thanks in advance for reading this post and thinking of a solution




Your only chance, if this system is important enough, is to reinstall only to db:

rpm -Uvh --justdb <package>

You could use your /root/install.log and /var/log/yum.log to get a list of installed RPMs, or, if you have a similar system you could get the RPM list from there.

That said, if this system can suffer downtime, I'd suggest re-installing as the best way. Otherwise, see the comment above.

Best of luck

| improve this answer | |
  • On RHEL/Fedora/Centos there should also be /var/log/rpmpkgs created by a cronjob, you can use this as a manifest file to RPM but you still need to download all the files into a directory and do the justdb install with the manifest file rather than <package> – user9939 Jul 27 '09 at 20:50

Edit: I read wrong -- if you removed the entire /var/lib/rpm directory you are a bit hosed.

You said you already did this first step, but for future reference (and for anyone else that runs into this)

delete /var/lib/rpm/__db.*


rpmdb –rebuilddb

It's not really a big deal, your system isn't hosed. Just run the above command(s) and you should be back in business.

| improve this answer | |

If you've kept a backup, then you might be able to restore it. Otherwise, you've wiped the only copy of the RPM database. (The rpm --rebuilddb command rebuilds some files in that directory from others.) Your system is basically hosed.

| improve this answer | |

I've never tried to, but you can try to set up a new empty RPM database (copy from fresh install?) and reinstall all currently installed packages in the current installed versions. You may have a look into your rpm (or maybe yum, if you're using it) logs to determine currently installed packages.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.