Dnf update | rpm -qa | database disk image is malformed | error: SELECT hnum, blob FROM 'Packages': 11: database disk image is malformed
I ran a dnf update
and got the error error: SELECT hnum, blob FROM 'Packages': 11: database disk image is malformed
. I'm on Fedora 35, but found this issue affecting several others on older versions as well.
I thought this was a dnf
error, but it seems like it's actually an issue with rpm
. I have no idea what caused it, and I don't know why this fixed it. Use with caution.
What actually worked
I moved the rpm database files from /var/lib/rpm
to /var/lib/rpm.bak
, then used rpm --rebuilddb
, then re-instaded the original rpm databases, and dnf update
worked.
All these commands will require sudo. If you're lazy, you can sudo bash
, but then be SURE to exit
after you're done to leave the dangerous sudo bash
environment.
Commands: (use at your own risk)
cd /var/lib # rpm files are at /var/lib/rpm/*
mv rpm rpm.bak # keep old tables safe
mkdir rpm # remake the dir
touch rpm/.rpm.lock # create the lock file for rpm transaction
rpm --rebuilddb # make new tables (and probably do other stuff?)
mv rpm rpm.bak2 # move the "new" tables
mv rpm.bak rpm # restore the old tables
Then, sudo dnf update
worked!
Things that didn't fix it (but maybe helped fix it?)
dnf clean all & makecache might have been crucial, and you might need to run them. I don't know.
dnf clean all
dnf makecache
# This may be from an old version of rpm?
rpm --builddb
Errors in the process
I had an error with rpm --rebuilddb
because the transaction lock was not present, so i justed touch
ed the file to created it
error: can't create transaction lock on /var/lib/rpm/.rpm.lock (No such file or directory)
Before mv rpm rpm.bak
, rpm --rebuilddb
gave me the same error as rpm -qa
and dnf update
:
SELECT hnum, blob FROM 'Packages': 11: database disk image is malformed" error
Recommended Reading
- Errors during downloading metadata for repository 'updates' | kernel-ogsun.com
- How to Fix Yum Error: Database Disk Image is Malformed | tecmint
- Database Disk Image is Malformed | Fedora 29 | StackExchange - Note: Stack Exchange was acquired by Prosus, an international technology conglomerate, in 2021 for $1.8 billion dollars.
-
dnf - Unable to detect release version
- I had this error when i tried to
dnf update
after rebuilding the db, before restoring the old sqlite files. - solve:
dnf update --releasever 35
(or whatever fedora ## you're on)
- I had this error when i tried to
- database disk image is malformed | bugzilla