3

I have a machine which has a directory that seems corrupt. The output of ls -lah is something like:

???????????  ? ?        ?           ?            ? dir_name

This used to be a valid directory in a CentOS 7 VM on SSD. I don't know what happened but now I just want to delete it, but that does not seem possible:

$sudo rm -rf dir_name 
rm: cannot remove ‘dir_name’: Is a directory

And stat can't read it either:

stat dir_name
stat: cannot stat ‘dir_name’: No such device

What's the simplest way to have this directory safely deleted?

2 Answers 2

6

You cannot delete corrupted dirs.

You must umount the filesystem and perform a fsck

as per man 8 fsck

fsck - check and repair a Linux filesystem

2

Although the generic answer was given, just want to point out that in my particular case, this directory was also used as an SMB (cifs) mount point, which I could see with the mount command. So the solution was to simply do:

sudo umount /home/user/dir_name

And then the directory looked normal again and I was able to delete it as usual.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .