Thursday, March 31, 2016

Removing folders with corrupt files

Lets say that you have a folder that you cannot remove, you issue a rm -r command:


mpjanic@valkyr:/home/diskstation/RNAseq/HCASMC/Raw_Data/Penn_2nd_round_RNAseq_GOOD_cvrg_8-11-15$ rm -r 2913_26442_GCCAAT/
rm: cannot remove 2913_26442_GCCAAT/GenomeForPass2/cifsfde9: No such file or directory
rm: cannot remove 2913_26442_GCCAAT/GenomeForPass2/cifsfdf1: No such file or directory
rm: cannot remove 2913_26442_GCCAAT/GenomeForPass2/cifsfdf9: No such file or directory
rm: cannot remove 2913_26442_GCCAAT/GenomeForPass2/cifsfe01: No such file or directory
rm: cannot remove 2913_26442_GCCAAT/GenomeForPass2/cifsfe0d: No such file or directory
rm: cannot remove 2913_26442_GCCAAT/GenomeForPass2/cifsfe19: No such file or directory
rm: cannot remove 2913_26442_GCCAAT/GenomeForPass2/cifsfe21: No such file or directory
rm: cannot remove 2913_26442_GCCAAT/GenomeForPass2/cifsfe2b: No such file or directory
rm: cannot remove 2913_26442_GCCAAT/GenomeForPass2/cifsfe33: No such file or directory
rm: cannot remove 2913_26442_GCCAAT/GenomeForPass2/cifsfe3b: No such file or directory
rm: cannot remove 2913_26442_GCCAAT/GenomeForPass2/cifsfe43: No such file or directory
Apparently you have some files in that folder, but when rm command tries to remove them the output is - No such file...

Similarly, it is not possible to remove files separately nor if you find inodes for each element in the folder with ls -i and try to delete them using find . -inum NUMBER -delete


ls -i
24422 cifsfde9  24423 cifsfdf1  24424 cifsfdf9  24425 cifsfe01  24426 cifsfe0d  24427 cifsfe19  24428 cifsfe21  24429 cifsfe2b  24430 cifsfe33  24431 cifsfe3b  24432 cifsfe43
find . -inum 24422 -delete
find: cannot delete `./cifsfde9': No such file or directory
One could possibly use fsck to check the filesystem or run sudo debugfs to delete files using their inodes (look up for detailed info on this as you can severely damage your filesystem).

However, a simple solution worked for me, rename a folder with mv and delete it.

mv 2913_26442_GCCAAT/ 2913_26442_GCCAAT2
rm -r 2913_26442_GCCAAT2/
ls -l 2913_26442_GCCAAT*
ls: cannot access 2913_26442_GCCAAT*: No such file or directory

No comments:

Post a Comment