I have a hard drive with windows loaded on it hooked up to my Linux machine for backing up some of the information. I want to delete one of the 'temporary internet files' folders and it deleted all but one of them. It returned an error with (with being the path leading through some directories):

rm: cannot remove '<path>/dorothy[1].js': Is a directory

I then used cd to get to where the file was and ran this:

rm -rf dorothy[1].js

It returned with no error, but if I ls it still shows up in the directory. I have also tried using these two methods of removing it as well, but to no avail (With <inode> being the inode of the filename).

ls -i  
find . -inode <inode> -delete  
find . -inode <inode> -exec rm {} \.

I then tried doing cd dorothy[1].js which worked. Once inside i used ls which returned this:

ls: reading directory.: Input/output error

So how do I delete this?

  • 1
    Perhaps a ls -l would help – Ed Heal Jul 17 '15 at 2:52
  • A ls -l inside of the directory holding dorothy[1].js came up with this: total 4 \n drwxrwxrwx 1 root root 4096 Jun 25 13:25 dorothy[1].js Doing a ls -l inside dorothy[1].js returns with this: ls: reading directory .: Input/output error \n total 0. Sorry for poor formating, im new to posting these types of things. – pehnquihn Jul 17 '15 at 3:12
  • And the directory itself. – Ed Heal Jul 17 '15 at 3:14
  • I edited my previous comment to include what I believe you mean the directory itself. Is that what you were looking for? – pehnquihn Jul 17 '15 at 3:17
  • Time for an fsck. – Mat Jul 17 '15 at 4:50

You have an NTFS filesystem. In this case you cannot safely fix the problem on anything except a Windows machine. (The Linux code is good, but I cannot recommend you trust it to fix a foreign filesystem.)

Take the disk to your Windows system and run CHKDSK /F Q:, or whatever drive letter it's been assigned. Then try deleting the file. If that fails you're going to need to wait for CHKDSK /R Q:, which may take many hours to run.

  • 1
    This is the right answer! And this is probably why. – mikeserv Jul 17 '15 at 17:55

Refer to Mat's comment.

It is time for fsck.

The situation you describe is rare. It appears you have at least two inodes pointed to dorothy[1].js + the directory entry for one inode is corrupt + thinks it's pointing to a directory.

This should never happen, unless you're using dev/beta code for a filesystem.

First run fsck. Then ensure you're running stable filesystem code, which you likely are. Then the next step is to look at any custom code that's been written that mucks about (technical term) in the physical directory structure on disk (shudder).

Also your file name is interesting as it contains '[]' chars which will expand to some form of regular expression in many cases. This may or may not have anything to do with your situation.

If after an fsck everything works + the problem reoccurs, you're likely in for some long debugging starting by posting you kernel version + all software packages installed on your system.

  • Just to reiterate my comment after Mat's, this drive is the NTFS filesystem format which is also mounted. After looking a little bit into fsck, it said it should never be used on a mounted drive. Should I still use it? – pehnquihn Jul 17 '15 at 16:51
  • 1
    @pehnquihn No! NEVER EVER EVER on a mounted filesystem – roaima Jul 17 '15 at 17:29
  • 1
    @pehnquihn - do not fsck that ntfs disk. follow @roaima's advice in the other answer. – mikeserv Jul 17 '15 at 17:57

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.