Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

Regards

amRit

share|improve this question
add comment

4 Answers 4

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

share|improve this answer
    
thanks for helping !!! –  anpcre Jul 27 '09 at 10:08
    
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> –  Paul Nasrat Jul 27 '09 at 20:50
add comment

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.*

then

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.

share|improve this answer
    
thanks for helping !!! –  anpcre Jul 27 '09 at 10:09
add comment

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.

share|improve this answer
    
thanks for helping !!! –  anpcre Jul 27 '09 at 10:08
add comment

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.

share|improve this answer
    
thanks for helping !!! –  anpcre Jul 27 '09 at 10:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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