How to remove a corrupted dir in an ext4 FS?

Asked by melendro

After a corruption in an ext4 filesystem, I've checked and move to the correct position all the files in lost+found, but one of them is corrupted.

The "ls -l" command says:
d????????? ? ? ? ? ? #90116

If I try to remove it, "rmdir" says:
rmdir: failed to remove `#90116': Input/output error

Running "fsck" says that the filesystem is OK.

Is there a way to remove that corrupted dir?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
melendro
Solved:
Last query:
Last reply:
Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#1
Revision history for this message
Sam_ (and-sam) said :
#2
Revision history for this message
melendro (melendro) said :
#3

I've tried all rm and rmdir options:

rmdir
rm
rm -r
rm -f
rm -fr

but the answer is always the same:

<command used>: failed to remove `#90116': Input/output error

Revision history for this message
melendro (melendro) said :
#4

Sorry, I fprgot to say that I've also tried renaming the file: same answer.

Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#5

Be sure to your filesystem do not have still errors in it, boot from live cd and perform a filesystem check, consider to replace your hard-disk and please do a backup of your relevant data.

Be sure to have an install cd to reinstall your system...

Revision history for this message
melendro (melendro) said :
#6

Long story:

The machine was not bootable because of the corruption, so I booted from the Live CD and run fsck. The result was that the /etc dir disappeared and all its contents were in lost+found.

I had two options: reinstall from scratch or create a new /etc and move the files in lost+found there. There were more than 400 files and dirs in lost+found and I had to find out the correct name of each of them, but I chose that option because the machine is a media center and I had to configure a lot of things in the beginning (xbmc, lirc, etc.) and it took a lot of time. I've managed to find out the name of all the files comparing their content with the /etc dir in the Live CD (and it only took me two days...).

Now there is only one dir missing in lost+found, I think it is the original /etc dir, and I don't need it but it cannot be removed because of the "Input/output error". fsck now tells that the FS is OK, and I've run it with the -c option to check for bad blocks, but it keeps saying that the FS is OK and checking the bad blocks founds with "dumpe2fs -b" there is no bad blocks, so I think that the problem was a software corruption and my disk is fine.

If the file cannot be removed in any way, I will let it live in lost+found forever, but I would like to clean up the lost+found dir (if possible).

Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#7

In so damaged system the better solution is to reinstall from scratch to be sure to have a good system.

Revision history for this message
Sam_ (and-sam) said :
#8

Could it be that some process is still writing to the file?
Try to remove it ( -rfv) and compare timestamps of ps -ef.

Revision history for this message
melendro (melendro) said :
#9

Just in case somebody arrives here looking for the same problem, I've managed to remove the corrupted dir with the following procedure:

1.- unmount the file system or boot from the live CD if it cannot be unmounted
2.- Run the following command (of course changing the filename and the device)
     debugfs -w -R 'rmdir /lost+found/#90116' /dev/sda1
3.- Mount the filesystem again or reboot from the hard disk

Be careful with the command in step 2. Before running the command be completely sure that dir name and the device are the correct ones.

Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#10

Thank to share this info...