On Fri, 2009-06-12 at 21:36, robin wrote:
> Whenever I rpm or urpmi something, I get the following message:
>
> rpmdb: read: 0x4014b274, 4096: Input/output error
> rpmdb: Hash bucket 428 maps to non-hash page 518
> error: db3 error(-30985) from db->verify: DB_VERIFY_BAD: Database
> verification failed
>
> I assume my database is corrupt, but how do I fix it (I tried rpm
> --rebuilddb to no avail)?
>
> Sir Robin
Robin, I searched thru my personal archives here and dug this up just
for you. Someone posted the URL to this text a while back and I took
the time to commit the content of the web page to the hard drive.
Basically this procedure builds a text list of all rpm's that are
currently on the system using the "find" command, and then works up from
there; so the final rpm database result should (theoretically) be a
mirror image of what you actually have. Not too shabby an idea;
although he does mention some caveats below that you should be aware
of. This looks to be a procedure that should be refined and integrated
into Mandrake as a "factory" script some time in the future; it's a
major achilles heel of rpm based Linux systems right now.
So here it is:
_____________________________________________________________________
On one of my Mandrake Linux systems, I had once this problem:
[pascal@hermes pascal]$ su
Password:
[root@hermes pascal]# rpm -q -a
failed to open //var/lib/rpm/packages.rpm
rpmQuery: rpmdbOpen() failed
[root@hermes pascal]# rpm --rebuilddb
failed to open //var/lib/rpm/packages.rpm
[root@hermes pascal]# rpm --initdb
[root@hermes pascal]# rpm -q -a
failed to open //var/lib/rpm/packages.rpm
rpmQuery: rpmdbOpen() failed
[root@hermes pascal]# rpm --version
RPM version 3.0.3
Well, clearly the RPM database was completely out of usage. I had to rebuild it.
You may think that it's simply a matter of using :
rpm --rebuilddb
However, I learned that --rebuilddb is REALLY AND COMPLETELY USELESS. Maybe the
authors and contributors to rpm could take some idea from this NFAQ to actually
implement a true --rebuilddb option.
The main idea of the process is to use:
rm -f /var/lib/rpm/* ; rpm --initdb
and:
rpm -i -v --nodeps --noscripts --notriggers --excludepath / packages...
to fill a package database without really installing anything (not overriding
installed files, not running any script, ...). This is done in the seventh step;
everything before I made to recover a list of installed packages.
This is not perfect, since some packages I have upgraded or modified the sources
and upgraded. I should have checked for /usr/src/RPMS too; I'll update the
database later by hand to synchronize it with the handful of packages I touched
after the initial installation.
+------------------------------------------------------------------+
| COOKBOOK PROCEDURE TO REBUILD A RPM DATABASE DAMAGED BEYOND HOPE |
+------------------------------------------------------------------+
####
#### BEWARE, THIS IS NOT AN AUTOMATIC SCRIPT!
####
#### Use this only as a guideline to rebuild your rpm database.
####
#####
# 1 # Find the files currently installed.
# # ON THE HOST WHO LOST ITS RPM DATABASE.
#####
find / -print | sort > /tmp/dsk-contents
#####
# 2 # Find all the files installed by the installation RPMs,
# # with their corresponding RPM.
#####
losetup /dev/loop0 /mnt/usr3/mandrake/mandrake61-1.iso
mount -o ro -t iso9660 /dev/loop0 /mnt/cdrom
cd /mnt/cdrom/Mandrake/RPMS
rm -f /tmp/rpm-contents
for f in *.rpm ; do
rpm -q -l -p $f \
| awk -v pn=$f '{printf "%s:%s\n",pn,$0;}' >> /tmp/rpm-contents
done
sort -t: +1 -o /tmp/rpm-contents /tmp/rpm-contents
#####
# 3 # Obtain the actually installed RPMs.
#####
gzip -d < lgetvalue-src.tar.gz | tar xf -
cd lgetvalue-src
make all test
./lgetvalue --field-separator=: \
--key-position=2 \
--value-position=1 \
/tmp/rpm-contents /tmp/dsk-contents \
| sort -u > /tmp/rpm-installed
#####
# 4 # Reinitialize a new rpm database.
#####
mv /var/lib/rpm /var/lib/rpm-damaged-beyond-hope
mkdir /var/lib/rpm
rpm --initdb
#####
# 5 # Let rpm say what problems there may be
# # (trying to do a pseudo-installation.
#####
cd /mnt/cdrom/Mandrake/RPMS
rpm -i -v --noscripts --notriggers --excludepath / `cat /tmp/rpm-installed`
#####
# 6 # Correct the list of installed RPMs.
#####
emacs /tmp/rpm-installed
#####
# 7 # Rebuild the rpm data base, without installing any file
# # nor running any script.
#####
rpm -i -v --nodeps --noscripts --notriggers --excludepath / \
`cat /tmp/rpm-installed `
#####
# 8 # Check you have a valid rpm database.
#####
rpm -q -a
____________________________________________________________________
HTH !!
LX
Want to buy your Pack or Services from MandrakeSoft?
Go to http://www.mandrakestore.com