What to do when yum fails
by Matt Giwer, © 2009 [Jan 30]

When any other applications fails from being corrupted it is trivial to run

yum --reinstall corrupted.rpm
and your problem is solved. But what do you do when yum becomes corrupted?

This has happened to me twice. The first time I could find no solution and simply waited out the time until the next Fedora release was available and did a fresh install. This time I solved the problem. Unfortunately I did not take notes on exactly what I did. The good news is I remember the process.

What apparently happened was the power dropped when the rpm database was doing its daily update. I got corrupt files in the database subdirectory and yum itself was corrupted.

When you run yum and it fails due to being corrupted it will give you the location of the database files. Go there. I did not take notes but I got the hints on where to find the database files by carefully reading the output. The subdirectory is named yum.

What you will find with ls -l in this yum directory are several files with attributes full of question marks (?) and names with leading underscores (_) and the kernal declaring them unreadable. They also cannot be removed, renamed, or touched in any way.

So cd .. to one level above this directory. Make a directory such as yum-temp, copy all the files from yum to yum-temp which will be only the good files, move yum to yum-orig and move yum-temp to yum. Then do

rpm --initdb 
and get a cup of coffee. The needed database is available after your second cup.

Go to your installation disk and find the yum-x-x-x.rpm under Packages. I used Fedora 10. You have to use an rpm file. It does not matter where you get it.

rpm -e --nodeps yum [may need version which you can get from conflicts list]
To get a list of conflicts simply run rpm -i yum. In detailing the conflicts if will give you the version installed.

The --nodeps is the trick to removing only yum and none of the dependencies and then

rpm -i yum-on-installation-disk.rpm
These two steps appear to be the same as the single
yum reinstall package.rpm
operation.

After this yum functions as expected. The first step is obviously

yum -y update yum
to get you back to where you were before the file was corrupted.