cPanel Linux Commands SERVER MANAGEMENT

How to rebuild RPM database?

rebuild rpm database
rebuild rpm database

Rebuild RPM database

Many of the clients are reporting their RPM database is corrupted. Please check the below method to rebuild RPM database. Working behind the scenes of the package manager is the RPM database, stored in /var/lib/rpm. It consists of a single database ( Packages ) containing all of the meta information of the installed rpms.

Check if there is any process is keeping rpm database open.

lsof | grep /var/lib/rpm

Kill all running processes using kill -9 command.

Delete the temporary db files.

rm -fv /var/lib/rpm/__*

Then rebuild the RPM database using below command.

rpm --rebuilddb -v -v

In case, if rpm –rebuilddb doesn’t help to rebuild the database and also copying required files from other good working node fail, then the last option is to re-install the rpm utility from rescue mode.

  • Download the rpm for installing rpm (example : rpm-4.8.0-47.el6.x86_64) utility and place it in server say under /tmp
  • Boot the server in rescue mode using cdrom/diag.iso
  • Once server booted from rescue medium, mount the root file system to a temporary location
mount /dev/sda1 /mnt/rescue
  • Install the rpm utility as below by manually specifying root location as the temporarily mounted one.
rpm -ivh --root=/mnt/rescue /mnt/rescue/tmp/rpm-4.8.0-47.el6.x86_64
  • Change the root file system
chroot /mnt/rescue
  • Verify that your rpm database is good now and all rpm related commands are working now.
rpm -qa
  • Reboot the server to boot in normal mode.

That’s it!

If you like the post and wish to receive more articles from us, please like our FB page: If you like this post and wish to receive more articles from us, please like our FB page: Button

Your suggestions and feedbacks will encourage us and help to improve further, please feel free to write your comments.

For more details on our services, please drop us an E-mail at