FROM: Jeff Johnson DATE: 02/28/2002 15:09:33 SUBJECT: RE: How do you fix a corrupt rpm database? On Thu, Feb 28, 2002 at 04:34:05PM -0600, wrote: > I have a problem using up2date. The rpm database is corrupted. rpm --rebuilddb > fails as does --initdb. When using up2date, I get a number of error that specify > a number of errors by line. > > Is there some tool that can fix this? No single tool, but here's what I do: 0) Make a copy of everything, just in case: cd /var/lib tar czvf /tmp/rpmdb.tar.gz rpm 1) Check /var/lib/rpm/Packages with db_verify. The command is db_verify /var/lib/rpm/Packages If that fails, the fix is cd /var/lib/rpm mv Packages Packages-ORIG db_dump Packages-ORIG | db_load Packages At this point Packages should be OK. 2) Read all Package headers. The command is rpm -qa If that "works", go to step 5), do "rpm --rebuilddb" and you're done. If that segfaults, go to 3). if that hangs, then do rm -f /var/lib/rpm/__db* and try again. 3) You have a segfault on a header. The first step is to get the segfaulting header instance. Append "debug" to the Packages configuration by echo "%_dbi_config_Packages %{_dbi_htconfig} lockdbfd debug" \ > /etc/rpm/macros Try "rpm -qa", lots of boring glop until segfault. On the screen will be something like ... Get Packages key (0x8216580,4) data (0x4014f008,155244) "#612" 47000000 rc 0kernel-enterprise-2.4.9-26beta.17 Get Packages key ((nil),0) data ((nil),0) "" deadbeef rc -30990 The 2nd to last "Get Packages" line is what you want, the bad header instance above is "612" in decimal. Note the package name-version-release, you'll want to reinstall that package somewhen. 4) Nuke the bad header. I usually whip out my handy-dandy header instance deleter, edit the bad record into the source, compile, run, and go back to step 2). The program is at ftp://people.redhat.com/jbj/t38454.c FWIW, the program is named after the bugzilla report that caused me to write it. Retrieve, and edit the bad header instances into ... int badrecs[] = { --> EDIT --> 562, 566, 559, 561, 563, 560, 564, -1 }; ... Compile with cc -o t38454 t38454.c -ldb-3.2 Run as t38454 Go back to step 2). 5) Clean up. a) rpm --rebuilddb b) rm -f /etc/rpm/macros c) rm -rf /var/lib/rpmrebuild* d) Reinstall the deleted package. Otherwise, give me a bug report at http://bugzilla.redhat.com with a pointer (i.e. URL, bugzilla attachments won't work) to the tarball you created in step 0), and I'll see what I can figger. 73 de Jeff -- Jeff Johnson ARS N3NPQ () Chapel Hill, NC _______________________________________________ Rpm-list mailing list https://listman.redhat.com/mailman/listinfo/rpm-list