1

In order to find a workaround for a problem I had yesterday (see the question here) I come out with another experiment.

After inserting a flash drive (vfat) and mounting its only partition I wondered: What if I change the permissions on the mount point? Well, that should solve all my problems so I proceed(as root):

At first I tried to change the owner:

root# chown root:root /media/MOUNT_POINT

Note: /media/MOUNT_POINT was created automatically by the system

What a surprise when the command answer was: Operation not permited. What? there is things that are not allowed even being root?

Ok, that don't stopped me and then tried:

root# chown 000 /media/MOUNT_POINT

this time, no messages, but after

ls -l /media

I got

drwx------  4  miranda miranda 4096 Apr 10 05:41 24EE-9E3C

as you can see, the folder still have all its permissions. I tried all combinations from 000 to 666 (with a script of course) and the result was the same.

What's happening? What I'm missing? or even more important. Can this be done?

Thanks in advance.

  • Is the flash media write-protected? – Jenny D Apr 10 '14 at 13:23
  • No, it isn't. In fact, that's the effect I'm looking for. – Raydel Miranda Apr 10 '14 at 13:27
3

The vfat filesystem does not support permissions. When you try to modify ownership or permissions on the mount point while the partition is mounted, it applies to the root directory of the mounted file system, not the directory that you are mounting on top of.

If your goal is to make the filesystem read-only, try mounting with -o ro.

You can do it without unmounting with mount -o remount,ro /media/MOUNT_POINT.

  • Ok. I'm aware vfat does not support permissions. I'm trying to change the permissions of the mountpoint not of the files or folders in the vfat filesystem. – Raydel Miranda Apr 10 '14 at 13:38
  • While it is mounted? If so, you're going to be affecting the root directory of the vfat partition you're mounting. You may need to umount the partition before you chown/chmod the mount point. – cpugeniusmv Apr 10 '14 at 13:43
  • You may be able to do it while mounted with: mount -o bind /media/ /mnt; chown root:root /mnt/MOUNT_POINT – cpugeniusmv Apr 10 '14 at 13:45
  • 1
    Note that vfat supports read-only files, you can use chmod a-w to set this attribute. – Graeme Apr 10 '14 at 13:53
  • @cpugeniusmv the option of doing with -o remount give me a good feeling. I'll test it right now. – Raydel Miranda Apr 10 '14 at 13:59
-1

Apparently, El Capitan includes a feature called System Integrity Protection (SIP) that prevents crucial directories from being modified. In the output above, that's indicated by the "restricted" flag. As of this writing, my research indicates the only way around this is to reboot, disable SIP, make changes, reboot, enable SIP. You can find the procedure outlined on Stack Overflow, but I'll re-print it here for ease of use.

Reboot. Press Cmd+R to enter Recovery mode. Open Utilities->Terminal. Run the command csrutil disable. Reboot. You are back in OS X with SIP disabled. Make your changes. Reboot. Press Cmd+R to enter Recovery mode. Open Utilities->Terminal. Run the command csrutil enable. Reboot.

  • There is nothing at all in the question to indicate that it's about MacOSX. Also, it was posted more than a year before El Capitan was released. – Jenny D Dec 2 '15 at 9:32
  • @JennyD You're right about the question not being about MaOSX, I´m adding the linux tag now. – Raydel Miranda Dec 2 '15 at 16:16

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.