8

I got into a weird situation. I got a 1Tb portable HD filled with some contents. It was used in Windows and as always packed with virus. I tried deleting some folders as root. But the following error returned

rm -R RECYCLER/
rm: cannot remove `RECYCLER/S-1-5-21-1659004503-1644491937-725345543-1003/Dc39.pptx': Operation not permitted
rm: cannot remove `RECYCLER/S-1-5-21-1659004503-1644491937-725345543-1003/Dc58.docx': Operation not permitted
rm: cannot remove `RECYCLER/S-1-5-21-1659004503-1644491937-725345543-1003/Dc17.JPG': Operation not permitted

ls -l returned

Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf898cc8b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1      121602   976760536    7  HPFS/NTFS

ls -l RECYCLER/
total 12
drwxrwxrwx 1 user user 12288 Dec 11 21:13 S-1-5-21-1659004503-1644491937-725345543-1003
4
  • 1
    What is the drive mounted as?
    – Hello71
    Dec 29, 2011 at 16:06
  • 1
    Its automounted in /media as with NTFS as the FS
    – user61954
    Dec 29, 2011 at 16:21
  • Extended attributes or ACLs on the files?
    – Daniel Beck
    Dec 29, 2011 at 16:30
  • Is it possible that your drive is mounted as read-only? Executing mount provides this information.
    – Dennis
    Dec 29, 2011 at 16:30

5 Answers 5

5

The directory RECYCLER/S-1-5-21-1659004503-1644491937-725345543-1003 is presumably read-only. Run chmod -R u+w RECYCLER to set write permission on directories, then rm -rf RECYCLER.

If this is through a FUSE filesystem, it's possible that only the user who mounted the filesystem has write permission on it. In that case, run su user rm -rf RECYCLER.

3
  • When I run chmod -R u+w RECYCLER it gives the operation not permitted. I tried even running chown command
    – user61954
    Dec 29, 2011 at 16:23
  • @user61954 NTFS is usually provided through FUSE (via ntfs-3g) these days, so try su user … (second paragraph of my answer). Dec 29, 2011 at 16:37
  • 2
    Installed ntfs-3g and now it works fine :)
    – user61954
    Dec 30, 2011 at 2:48
8

This is due to an immutable attribute set for the files. If your filesystem driver allows it, run the command below before removing it.

chattr -i RECYCLER/S-1-5-21-1659004503-1644491937-725345543-1003/*
rm -f RECYCLER/S-1-5-21-1659004503-1644491937-725345543-1003/*
1
  • Works on Ubuntu 18.04 Apr 16, 2021 at 21:44
0

On debian you can use the fsck.ntfs command.

I think the Package is called NTFSProgs.

0

Looks like some filesystem issues. Try chkdsk /F [Harddrive]: on a windows PC.

Example:

chkdsk /F E:

3
  • Sorry, I dont have windows
    – user61954
    Dec 29, 2011 at 16:22
  • If it's not going to be used on Windows again, I suggest you backup the useful files and reformat it with ext4 or other Linux-native filesystems.
    – netvope
    Dec 30, 2011 at 0:46
  • The probelem is that its owner uses Windows :D
    – user61954
    Dec 30, 2011 at 2:28
-1

I had this problem on my Note 3 (Android device) with some files in a folder on the external SD card. rm produced "operation not permitted" and lsattr produced "inappropriate ioctl for device".

The fix for me was to take the SD card out of the phone and put it into a PC to delete the files. Worked like a charm. I know that's not exactly a "linux" solution but it's the only thing that worked. Hopefully this will help someone else.

3
  • 1
    This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation.
    – warren
    Jul 21, 2014 at 19:41
  • @warren: What question does this not answer? The original question does not really ask a question. Implicitly, it asks, "How do I remove contents from a Windows disk?" Dubious is (somewhat anecdotally) answering, "Put the disk back on a Windows system and do it there." It's no less of an answer than Daniel's first answer. OK, yes, user61954 says that [s]he doesn't have Windows; hence Dubious's disclaimer that he hopes this will help someone else. Jul 21, 2014 at 19:52
  • 1
    @Scott - the question is about external hard drives and linux: Dubious' answer is about an SD card from an Android device that needed to be deleted using Windows. The answer has nothing to do with the question, and is barely tangentially similar.
    – warren
    Jul 21, 2014 at 22:32

You must log in to answer this question.

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