Home / Linux/Unix/BSD / Yum sqlite database disk image is malformed error

Yum sqlite database disk image is malformed error

When trying to install something this morning using yum on a CentOS 5 machine, I got the error message “_sqlite.DatabaseError: database disk image is malformed” as shown below:

$ yum install vsftpd
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
base                      100% |=========================| 1.1 kB    00:00
updates                   100% |=========================|  951 B    00:00
centosplus                100% |=========================|  951 B    00:00
addons                    100% |=========================|  951 B    00:00
extras                    100% |=========================| 1.1 kB    00:00
Reading repository metadata in from local files
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in ?
  File "/usr/share/yum-cli/yummain.py", line 94, in main
    result, resultmsgs = base.doCommands()
  File "/usr/share/yum-cli/cli.py", line 381, in doCommands
    return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd, self.extcmds)
  File "/usr/share/yum-cli/yumcommands.py", line 134, in doCommand
    return base.installPkgs(extcmds)
  File "/usr/share/yum-cli/cli.py", line 539, in installPkgs
  File "/usr/share/yum-cli/cli.py", line 109, in doRepoSetup
  File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 341, in doSackSetup
  File "/usr/lib/python2.4/site-packages/yum/packageSack.py", line 331, in excludeArchs
  File "/usr/lib/python2.4/site-packages/yum/sqlitesack.py", line 587, in excludeArchs
  File "/usr/lib/python2.4/site-packages/sqlite/main.py", line 244, in execute
    self.rs = self.con.db.execute(SQL)
_sqlite.DatabaseError: database disk image is malformed

This is easy to fix by issuing the following command:

yum clean allAfter running this I got the following message, and I was able to install software again using Yum:

Loading "installonlyn" plugin
Cleaning up Everything
This error could happen on any Linux distribution that uses Yum for package management, such as Red Hat Enterprise Linux, CentOS 5, Fedora and its derivatives.