fix error database disk image is malformed

How to Fix Yum Error: Database Disk Image is Malformed

When you use RHEL/Fedora/CentOS/SUSE Linux, you may sometimes get an error saying ‘Database Disk is Malformed’. In this article, we will learn how to fix this error.


How to Fix Yum Error: Database Disk Image is Malformed

Yum is the default package manager for RHEL/CentOS/SUSE/Fedora systems that allows you to download, install, upgrade update and uninstall packages on your system. From yum 3.2.26, it stores additional information about installed packages of your system in a flat file outside rpmdatabase in /var/lib/yum/yumdb. It is known as yumdb.

You can check its contents using ls command.

$ ls /var/lib/yum/yumdb

You will see a list of folders with alphabets as their folder name. In each of these folders, you will see files related to packages whose names begin with the letter corresponding to the folder name. These files contain information about the specific context in which the package was installed. You can easily retrieve meaningful information from yumdb using yum-utils.

# yum install yum-utils 

yum-utils ships with yumdb command that can be used to access information in yum database. Here is a command to get repo name of httpd package installed on your system.

# yumdb get from_repo httpd

You can also use yumdb command to make changes to existing files in yum database. Here is a command to set note in yumdb files of packages httpd and mariadb.

# yumdb set note "installed by user abc to setup LAMP" httpd

If you want to view all information about a package, use yumdb info command. Here is the command to get complete information about httpd package installed on your system.

# yumdb info httpd


Fix Yum Error: database disk image is malformed

Typically, when you install a package using Yum, you may get this error. It may be because the yumdb is corrupted, due to issues in ‘yum update’ command or during package installation. This is because whenever you run yum update or install a package using yum, yumdb will be updated. If this does not happen properly, or of it is terminated before completion then it may corrupt your yumdb.

To fix this error, clear the database cache, with the following command.

# yum clean dbcache 

If the above command does not work for some reason, try the commands listed below.

# yum clean all			#delete entries in /var/cache/yum/ directory.
# yum clean metadata		#clear XML metadeta		
# yum clean dbcache		#clear the cached files for database
# yum makecache		        #make cache

Next, you must rebuild your system’s RPM database to make it work as before.

# mv /var/lib/rpm/__db* /tmp
# rpm --rebuilddb

Finally, run yum update command to update it to the latest version.

# yum update

That’s it. At this point, your issue should have been fixed.

Also read:

How to Fix Failed to Mount /etc/fstab Error
How to Compress Images in Linux
How to Reduce PDF Size in Linux
How to Password Protect PDF in Linux
How to Remove PDF Password in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *