Possible Cause For Error
Yum is a well known tool used for installing packages on RPM based Linux distributions. It is most widely used package manager on Redhat Enterprise Linux, CentOS, and Fedora operating systems. Any other operating system derived from these distributions also use Yum for the installation, update or removal of software packages. If you are encountering following error message while updating or installing any packages, its obvious that something bad has happened to Yum.
Error: database disk image is malformed
It usually occurs once “yum update” process is interrupted, quite possible that your system went powered off during “yum update” process and it left yum database in a corrupt state, all we need to do is to clean and repair yum database to fix the error.
Fixing this Yum’s error
There are few steps to resolve this error, all pretty simple.
Clear Yum Caches
Clear yum cache by running the following command. It will ensure to remove entries from /var/cache/yum/ directory. Please note that it will not effect any of your currently installed packages. Pretty safe command to run.
Clear Yum’s XML meta deta by running the following command:
Run following command to clear the cached files for database.
It is important to clear Yum’s make cache, use following command:
Rebuild RPM Database
As the last step, make sure to rebuild your system’s RPM database. Run following two commands to achieve this.
That’s it, Yum error should be fixed now, re-try it, it should work just fine.