I store my data on a NTFS parition to share it with my Windows. I use the dmask,fmask option in my fstab entry to avoid rwx default permissions to everyone, for coherence, security, and also because my zsh color profile rendering is then ugly when listing.

/dev/sda5       /mnt/Data       auto    defaults,force,rw,uid=1000,gid=1000,dmask=027,fmask=137   0   0

The problem with f/dmask is that I can't change related permissions of files once it's mounted. For example, I have Unix scripts stored there; and when I try a chmod +x, the mask automatically discards any changes, even in root.

I thought about removing masks and automatically executing this kind of script :

chown -R me /mnt/Data
find -type f /mnt/Data -exec chmod -R 640 {} \;

but it isn't very elegant and can be very long for large amount of little imbricated files/directory. Is there any way or unknown (at least to me) option of mount to do that?


uid gid dmask fmask is mount's way of letting you specify owner, group and access permissions. Either you use it and accept the limitations, or you don't. There are a few options:

  1. Skip dmask fmask and adjust your zsh color profile. This seems like the easiest option.
  2. Keep your mount options and write a sudo-like script to temporarily remount the drive without dmask fmask, do the chmod and remount back with dmask fmask.

Imagine invoking it like:

remount-do /mnt/Data "chmod 755 /my/file"
  • Well, thanks. I guess I'll just change my color profile then, cause remounting the drive each time I want to set a +x is quite heavy
    – yago
    Jan 30 '14 at 21:51

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.