Default mount options on auto-mounted NTFS partitions (how to add `noexec` and `fmask=0111`?)

6,861

if the default mounting options are hard-coded, what I have to recompile to change them

Edit the file device.c with your custom defaults:

mkdir -p build/udisks
cd build/udisks
apt-get source udisks
gedit udisks-1.0.1/src/device.c

Search for ntfs_defaults, edit, save and exit.
If the mount option isn't already on ntfs_allow list below ntfs_defaults, must also add that new option to ntfs_allow.

Build (see the other answer for a pbuilder way):

cd udisks-1.0.1
dch -l custom "Mount custom defaults fix."
dpkg-buildpackage -b -us -uc -rfakeroot

Install the newly compiled udisk:

sudo dpkg -i ../udisks_1.0.1-1ubuntu1custom1_amd64.deb
Share:
6,861

Related videos on Youtube

SnowBEE
Author by

SnowBEE

Updated on September 17, 2022

Comments

  • SnowBEE
    SnowBEE over 1 year

    I use auto-mounting of external USB devices, and it works as expected, except that NTFS partitions are mounted with executability flag on. For example:

    /dev/sdb1 on /media/Elements type fuseblk (rw,nosuid,nodev,allow_other,blksize=4096,default_permissions)
    

    All normal files are -rwxrwxrwx on this partition. I am not happy with the xs. I know I can have it mounted the way I want if I pass the fmask=0111 option.

    Now I use Lucid, and suppose it uses some new auto-mounting mechanism (gvfs-mount?), but I don't really know how the default mounting options can be changed now. Gconf settings in /system/storage/default_options/ntfs/mount_options have no effect.

    So, how do I make fmask=0111 the default automounting option for all NTFS partitions? (I'd be grateful also if someone explains how the current automounting mechanism works, how to configure it, and if the default mounting options are hard-coded, what I have to recompile to change them).

    I know that I can put a line in the /etc/fstab and/or mount manually, but this is not the solution I want, because 1) I don't want to edit /etc/fstab for each and every external drive I use, 2) fstab records appear in the Places pane of Nautilus, even if the drives are not present. The questions is how to change the defaults.

    Update: installing udisks 1.0.1+git20100614 or later gives more sensible defaults for NTFS, the problem which remains is how the user can specify arbitrary mount options.

  • SnowBEE
    SnowBEE over 13 years
    This answers the wrong question. NTFS partitions work well in Linux, and the executable bit can be disabled on all files with fmask=0111 option. The question is how I can I configure the modern Ubuntu automounting mechanism?
  • HelloCoral
    HelloCoral over 13 years
    you can't, read the second paragraph. You would have to switch all of those drives to fat32 to keep them compatible and non-executable by default.
  • Ryan C. Thompson
    Ryan C. Thompson over 13 years
    Choosing FAT32 or NTFS has nothing to do with setting the fmask.
  • HelloCoral
    HelloCoral over 13 years
    But by default files on fat32 drives are set to not executable. Hence kind of a solution.
  • SnowBEE
    SnowBEE about 13 years
    1) I asked about NTFS, not FAT. 2) I don't see how the proposed patch (15-vfat-UTC.patch) would allow to configure noexec and fmask mount options for NTFS partitions. As is, your answer is offtopic and not useful.
  • Nilfred
    Nilfred about 13 years
    @jetxee 1) Look at the line: gedit udisks-1.0.1/src/device.c I don't want to help only you, but as general help. 2) Just an example about how to share your patch against your specific problem. I won't do your homework every time you want to change every other default. Just search for defaults when where in device.c
  • SnowBEE
    SnowBEE about 13 years
    1) your "general help" on how to build packages is incomplete, inappropriate and badly written, try to be more specific next time; your last edit at least makes the answer on-topic (+1), but you could have stopped after "new option to allow", without loads of copy-paste 2) I did my homeworks long time ago, and in particular, have already posted a similar workaround, the problem which remains is: it still doesn't allow to specify arbitrary mount options.
  • Nilfred
    Nilfred about 13 years
    @jetxee 1) You should build after edit device.c stoping there left another question open: How to build? 2) I found your self-answer useful to my specific problem, so I give to the community whats community gives to my: I specify arbitrary mount options following your directions (with customs detours) 3) You edited too much: my compile time is much less than yours and install less garbage than pbuilder 4) I agree to remove the share your changes part, that includes the cp -p backup line: apt-get source will undo just fine any fail.
  • SnowBEE
    SnowBEE about 13 years
    Agree. Now it is a well-written answer. Thank you.
  • Stefan Monov
    Stefan Monov over 7 years
    In my Ubuntu 16.04 files in NTFS partitions are still executable by default. I had to configure the drive in fstab to fix it.