How to recover rpm database using /var/log/rpmpkgs?

Solution Verified - Updated -


  • Red Hat Enterprise Linux (RHEL) 4
  • Red Hat Enterprise Linux (RHEL) 5
  • Red Hat Enterprise Linux (RHEL) 6


  • How to recover rpm database from scratch from file /var/lib/rpm/Packages?
  • How to rebuild rpm database using the /var/log/rpmpkgs file?
  • Completed steps to rebuild rpm database as mentioned in How to rebuild RPM database on a Red Hat Enterprise Linux system? without any error message, but rpm database is not rebuilt and does not list all packages installed. How to rebuild rpm database?


Note: In Red Hat Enterprise Linux 6, the daily cron file to create /var/log/rpmpkgs is provided by the rpm-cron package, available in the optional repository, not the main 'rpm' package. So, if you do not install the package, /var/log/rpmpkgs is not available on Red Hat Enterprise Linux 6.

Note: Even if /var/log/rpmpkgs is not available, the yumdb info command can output the installed package list (only for packages installed with yum). If no packages were installed with rpm, then a list of installed packages like /var/log/rpmpkgs can therefore be created from the output of 'yumdb info'.

  • Create the work directory:
# mkdir /var/tmp/recoverdb
  • Download all the necessary rpm files into the work directory:

    • For Red Hat Enterprise Linux 4 systems:

      # cat /var/log/rpmpkgs | sed 's,\.[^.]\+\.rpm$,,g' | while read nvr
            up2date --tmpdir=/var/tmp/recoverdb --get $nvr
    • For Red Hat Enterprise Linux 5 & 6 systems:

      • Confirm yum-utils package is installed on system.

        # yum install yum-utils
      • If this installation fails, download the package and install it manually:

        # rpm -Uvh --nodeps --force yum-utils*.rpm
      • Once yum-utils is installed, download all required packages.

        # cat /var/log/rpmpkgs | sed 's,\.[^.]\+\.rpm$,,g' | while read nvr
              yumdownloader --destdir=/var/tmp/recoverdb $nvr
  • Rebuild the rpm database:

# cd /var/tmp/recoverdb
# ls *.rpm > MANIFEST
# rpm -Uvh --noscripts --notriggers --force --justdb MANIFEST
  • Run yum / up2date to ensure the filesystem and the rpmdb are in sync.

    • For Red Hat Enterprise Linux 4 systems

      # up2date -uf
    • For Red Hat Enterprise Linux 5 & 6 systems

      # yum update
  • In the event of an error such as:

# rpm -Uvh --noscripts --notriggers --force --justdb MANIFEST
error: Failed dependencies:
        glibc-common = 2.3.4-2.57 is needed by (installed) glibc-2.3.4-2.57.i686
        glibc-headers = 2.3.4-2.57 is needed by (installed) glibc-devel-2.3.4-2.57.i386    

Download the missing rpms and place them in the directory.


Diagnostic Steps

  • If following packages are not present in the rpm database, then up2date will not work. Download and install them manually on the system
    basesystem, glibc, bash, mktemp, setup, redhat-release



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.


"Download the missing rpms and place them in the directory." should say:

Download the missing rpms, place them in the directory, rebuild your MANIFEST file (ls *.rpm > MANIFEST), and re-run 'rpm -Uvh --noscripts --notriggers --force --justdb MANIFEST'