Here is the situation. My UPS battery has recently died, and I've not replaced it yet. Today someone came over to do electrical work on the home, which involved shutting down the circuit breaker on which the computer sits. I'm smart enough to start shutting down my computer before I trip the breaker, but I was talking to the electrician and forgot to check that my computer was 100% down before tripping the breaker. The result:

When I log into one account, using KDE, during the login process I start getting errors like this: since I only get these errors when I log in as this person and only into KDE ( other DEs and other accounts with KDE OK ) I think it is safe to say that something in my kde configuration is screwed up.

1) I'm kind of freaked that I see this kind of error based on just a minor ( relatively speaking ) corruption error in a file system .
2) My kde configuration is kind of long and involved. I don't want to delete the whole thing and start over. Is there a way of logging the progress of a startup sequence to see when it encounters an error, so I can just delete that part of the configuration?

2 Answers
2

This has nothing to do with KDE; your drive has a bad sector. Since you had a sudden loss of power, what likely happened is the power went out mid way through writing to a sector, leaving it in a bad state. Whatever was being written at the time is lost, but you should be able to correct the problem by writing something to that sector now. First, run this:

sudo dd if=/dev/sda bs=512 count=1 of=/dev/null skip=326677146

That should fail with an IO error. If it does, proceed with writing zeros to that sector:

sudo dd if=/dev/zero bs=512 count=1 of=/dev/sda seek=326677146

This should work and then you should be able to repeat the first command without error. Then you should use smartctl from the smartmontools package to check the drive for errors. Run sudo smartctl -t long /dev/sda to start the drive's self test. Check its progress with sudo smartctl -a /dev/sda. If it finds more bad sectors, you can try using dd to correct those as well. You also want to make sure that the reallocated sector count is zero. If it is not, then there is physical damage to the disk and you should think about replacing it.

These errors do not indicate filesystem corruption, they indicate a problem with the disk. It's likely that the power outage caught the disk at a bad moment and one of the heads crashed onto the platter — disks are supposed to be protected against that, but this doesn't always work (there's often a power glitch before the power goes down completely).

If your disk supports it, run smartctl (from Smartmontools) and badblocks to get a damage assessment. Then make sure you have the whole disk backed up (ddrescue or dd_rescue might help — see saving data from a failing drive).

I recommend replacing the disk, as its reliability is compromised. If you want to play the lottery keep using it, run badblocks -o /tmp/badblocks then e2fsck -l /tmp/badblocks to mark the damaged sectors as unusable.

Heads don't crash from power loss, they crash from mechanical damage or shock.
–
psusiJul 22 '12 at 1:32

@psusi It's an indirect consequence: power loss → head not parked in the right position → it takes a smaller shock to cause damage.
–
GillesJul 22 '12 at 12:16

Heads haven't needed to be parked before power down since the early '90s. Drives now are designed to keep enough energy in reserve to retract the heads when the power fails, or use a spring or other mechanical means to fail safe. Some drives keep a count of how many times they have had to do an emergency retract and report it via SMART.
–
psusiJul 22 '12 at 22:32

In my experience, the disk is just fine, but you sometimes get a bad sector because it did not get completely written before the heads retracted ( thus, the ECC doesn't add up ). You can fix that by simply writing over the sector again and everything is fine, including zero reallocated sectors reported by SMART.
–
psusiJul 22 '12 at 22:41