5

How to remove a file that is corrupted?

In Linux (Fedora based), when I type: ls -l I get

drwxr-xr-x.  2 dmiller3 dmiller3     4096 Jul 26 13:57 SomeFile
??????????   ? ? ?                   4096 Jul 26 13:57 CorruptedFile  

I can't do anything with this CorruptedFile. I can't use it in delete or anything. It's the only file in the entire system that is like this. What causes this, and how can I remove it?

File system is ext2.

Michael Mrozek
  • 93,103
  • 40
  • 240
  • 233

2 Answers2

6

you could have been writing to a file during a hard reset, or your hard drive could have problems. a fsck should fix it (you will have to umount the fs to do this). I'd check dmesg and smartctl -a /dev/hdx (latter is part of smartmontools ) to see if your HD is reporting any errors. I'd also run a non-destructive badblocks on the partition.

You should also ask yourself why you are running ext2, because journaling tends to help with these kinds of problems.

xenoterracide
  • 59,188
  • 74
  • 187
  • 252
  • Thanks. Reason why we use ext2 is because it came from the vendor this way. It's a custom distro based on Fedora for embedded systems. You solution worked. – Dennis Miller Sep 02 '10 at 18:25
0

Some entertaining problems with filesystems I've seen were:

  • A file that only shows up when asked for specifically: "ls file" shows it, but a plain "ls" doesn't. What happened is that the next file had the escape sequence for "Go up a line" in its name
  • Files with impossible permissions/type: Fixed by a fsck(8), or just blowing the file away with rm(1)
  • Very deep directory tree, created by a miscreant creating directories and cd'ing into them in a loop: Had to write a program that went down to the end, and then backed up deleting a directory in a loop.
vonbrand
  • 18,253