What is the purpose of the '/var/lib/rpm' directory?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 9.
  • Red Hat Enterprise Linux 8.
  • Red Hat Enterprise Linux 7.
  • Red Hat Enterprise Linux 6.
  • Red Hat Enterprise Linux 5.

Issue

  • Is it safe to delete the contents of the /var/lib/rpm directory to free up the disk space?

Resolution

  • The /var/lib/rpm directory is a very crucial directory as it holds the RPM database of the system. Deleting files from /var/lib/rpm directory will break the system. It is always advised to back up the rpm database, especially before upgrading the system.
  • The RPM database holds information about all the RPM packages installed on the system. The database is accessed whenever the rpm command is issued, and it gets modified whenever a package is installed or removed. The RPM database is used to query what is installed and to verify if the system is properly setup from the packaging point of view.
  • The /var/lib/rpm directory usually contains the below files:
-rw-r--r--. 1 root root  4235264 Sep 20 11:26 Basenames
-rw-r--r--. 1 root root    16384 Sep 20 11:26 Conflictname
-rw-r--r--. 1 root root   270336 Oct  7 10:35 __db.001
-rw-r--r--. 1 root root    81920 Oct  7 10:35 __db.002
-rw-r--r--. 1 root root  1318912 Oct  7 10:35 __db.003
-rw-r--r--. 1 root root  1204224 Sep 20 11:26 Dirnames
-rw-r--r--. 1 root root    32768 Sep 20 11:26 Group
-rw-r--r--. 1 root root    20480 Sep 20 11:26 Installtid
-rw-r--r--. 1 root root    81920 Sep 20 11:26 Name
-rw-r--r--. 1 root root    32768 Sep 20 11:26 Obsoletename
-rw-r--r--. 1 root root 96436224 Sep 20 11:26 Packages
-rw-r--r--. 1 root root  2535424 Sep 20 11:26 Providename
-rw-r--r--. 1 root root   528384 Sep 20 11:26 Requirename
-rw-r--r--. 1 root root   131072 Sep 20 11:26 Sha1header
-rw-r--r--. 1 root root    73728 Sep 20 11:26 Sigmd5
-rw-r--r--. 1 root root     8192 Sep 20 11:25 Triggername
  • The above files make up the RPM database. The file __db.001 and similar files are lock files used by the RPM system. The other files are databases in Berkeley DB format. The most important file is the Packages file. The Packages file contains the header tag information for each package, indexed by an index number. This number slowly grows with time.
  • Component
  • rpm

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments