3

For some unknown reason, there are 2 directories I can't delete.

First directory called sw.old is empty and can be deleted only by rm, as rmdir won't recognize it. However, even after rm, it still shows up:

[02:11:36] user@user:/media/user/exthdd/docs$ ls -il
total 1072064
1456 drwx------ 1 user user          0 Aug 12 10:04 1old.or.probably.unfinished
5717 drwx------ 1 user user       8192 Jan 27 22:58 videos
6528 -rw------- 1 user user 1097779088 Nov  5 16:15 release_Remix_OS_for_PC_Android_M_64bit_B2016112101.zip
8008 drwx------ 1 user user       4096 Jan 28 00:55 txt
  64 drwx------ 1 user user          0 Dec 25 22:15 sw.old
[02:12:03] user@user:/media/user/exthdd/docs$ rmdir sw.old/
rmdir: failed to remove ‘sw.old/’: No such file or directory
[02:12:57] user@user:/media/user/exthdd/docs$ rm -rf sw.old/
[02:13:15] user@user:/media/user/exthdd/docs$ ls -il
total 1072064
1456 drwx------ 1 user user          0 Aug 12 10:04 1old.or.probably.unfinished
5717 drwx------ 1 user user       8192 Jan 27 22:58 videos
6528 -rw------- 1 user user 1097779088 Nov  5 16:15 release_Remix_OS_for_PC_Android_M_64bit_B2016112101.zip
8008 drwx------ 1 user user       4096 Jan 28 00:55 txt
  64 drwx------ 1 user user          0 Dec 25 22:15 sw.old

Second one called misc has a corrupted file inside it:

[02:24:32] user@user:/media/user/exthdd/docs/txt$ ls -il
total 0
22607 drwx------ 1 user user 0 Dec 31 16:09 misc
[02:24:36] user@user:/media/user/exthdd/docs/txt$ ls -il misc/
ls: cannot access misc/patterns.mp4: Input/output error
total 0
? -????????? ? ? ? ?            ? patterns.mp4
[02:24:54] user@user:/media/user/exthdd/docs/txt$ rm -rf misc/
rm: cannot remove ‘misc/patterns.mp4’: Input/output error

How can I remove those directories (and corrupted file inside one of them) without formatting?

  • 1
    Bear in mind that -f tells rm not to issue any error messages. So the lack of output from rm -rf sw.old/ doesn’t mean that it worked; it just means that it failed silently. Maybe there are invisible characters in the name. What does ls -ilb say? … … … … … … … … … … … … … … … … … OTOH, a directory should never have size 0, so you’ve probably got a corrupt filesystem. – G-Man Jan 28 '18 at 6:09
  • ls -ilb gives the same output, so I guess that won't be problem. Regarding corrupt filesystem, everything else on disk works fine, is there a chance there will be more problems like this if I don't format? – PKM Jan 28 '18 at 9:28
  • You should unmount your disk and do a fsck as there seems to be something wrong with the filesystem. Also check the health of your disk. – Thomas Jan 28 '18 at 11:14
0

I've only had that error message show up when there's been a problem accessing the drive itself. Given that it appears to be an external drive, I'd check the cable, interface, cable connections, and drive: if any of those aren't working properly, you'll get those errors.

Until you check the drive and run fsck on the filesystem, I'd recommend against trying anything further.

  • And take an extra backup first, at least if the disk contains anything important. Sometimes fsck can fix things; other times it just manages to make some hidden filesystem corruption clearly apparent, leaving a mess for the sysadmin to clean up. If that happens, it is very nice to have the "nuclear option" of just running mkfs and restoring a backup. – telcoM Jan 28 '18 at 1:37
  • @ErikF that's the weirdest thing because except those 2 "bedrock" directories, disk works very well and there are no any other problems with it – PKM Jan 28 '18 at 3:58
  • @telcoM right now I don't have enough time and storage to make an backup – PKM Jan 28 '18 at 4:00
  • Does dmesg show any kernel errors? – ErikF Jan 28 '18 at 4:13
  • @ErikF nope, no logs after trying to remove both of them – PKM Jan 28 '18 at 11:42
0

You can check what's writing to that location or file with lsof. For example:

lsof /media/user/exthdd/docs/

or even:

lsof / |grep sw.old

Additionally, you can create a backup on a separate disk or archive and try to fix the underlying filesystem if there is corruption. However, that depends on the filesystem type and/or storage setup you have in place.

  • lsof gives no output (so nothing is writing). And I can't do backup right now, that's why I'm trying do to it without wiping the whole drive – PKM Jan 28 '18 at 4:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.