Regenerating an RPM database from installed packages

Hi, not sure if this is the right subforum but I accidentally nuked my RPM database (/var/lib/rpm/Packages that is) while wanting to remove a shared lock (so /var/lib/rpm/.rpm.lock). Is there any way to regenerate a database without reinstalling all of my packages again, perhaps from my existing installed packages in /usr/bin or /sbin etc?

There is

rpm --rebuilddb

As you say you have lost the whole thing, trying it can not corrupt very much I guess :wink:

This might be what you are looking for:

SDB:RPM database corrupted

Hi, welcome

Please accept my advice to never remove the lock on the rpm database. That could seriously bork your system.

Already tried that, didn’t do anything in my case unfortunately and I’m not on btrfs so I can’t roll back either (XFS).

Will do, I guess I’m just gonna have to reinstall everything. Thanks for the replies tho


This command recreates other files from Packages. Without Packages you get empty RPM database with no packages.

Check /var/adm/backup/rpmdb, you may have copy of Packages there …

Thank you very much, yes I was able to retrieve a backup of that database (which includes basically everything I’ve installed anyways) from the backup and zypper works again.