9

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.

3

3 Answers 3

1

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
5
  • 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.
    – sastanin
    Apr 25, 2011 at 19:41
  • @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
    – Nilfred
    May 3, 2011 at 13:11
  • 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.
    – sastanin
    May 3, 2011 at 14:27
  • @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.
    – Nilfred
    May 5, 2011 at 21:36
  • Agree. Now it is a well-written answer. Thank you.
    – sastanin
    May 6, 2011 at 9:43
0

I found a workaround for the problem of executable files on Lucid (it shouldn't be required on Maverick). Newer udisks 1.0.1+git20100614 doesn't make all files on NTFS partition executable. This solves my particular problem with executable files, but it still doesn't allow to specify arbitrary mount options.

The following are step-by-step instruction how I built a back-ported udisks package.

Change directory to where you want to download the source packages and download them:

wget https://launchpad.net/ubuntu/maverick/+source/udisks/1.0.1+git20100614-1/+files/udisks_1.0.1+git20100614.orig.tar.gz
wget https://launchpad.net/ubuntu/maverick/+source/udisks/1.0.1+git20100614-1/+files/udisks_1.0.1+git20100614-1.debian.tar.gz 
wget https://launchpad.net/ubuntu/maverick/+source/udisks/1.0.1+git20100614-1/+files/udisks_1.0.1+git20100614-1.dsc 

To build newer udisks I used pbuilder:

sudo aptitude install pbuilder
sudo pbuilder create
sudo pbuilder --update
sudo pbuilder --build udisks_1.0.1+git20100614-1.dsc 

This may take some time but it worked for me. Now you can install the newly built package:

cd /var/cache/pbuilder/result/
ls *.deb
sudo dpkg -i udisks_1.0.1+git20100614-1_amd64.deb

This package should be preferred over the distribution (lucid) packages:

$ apt-cache policy udisks
udisks:
  Installed: 1.0.1+git20100614-1
  Candidate: 1.0.1+git20100614-1
  Version table:
 *** 1.0.1+git20100614-1 0
        100 /var/lib/dpkg/status
     1.0.1-1ubuntu1 0
        500 http://it.archive.ubuntu.com/ubuntu/ lucid-updates/main Packages
     1.0.1-1build1 0
        500 http://it.archive.ubuntu.com/ubuntu/ lucid/main Packages

Now the regular files on automatically mounted NTFS partitions are not executable anymore. I hope this fix finds its way into the official Lucid updates.

1
  • 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. Dec 9, 2016 at 15:53
-2

This is because NTFS drives aren't made for linux, they're made for Windows, and Windows makes everything executable by default.

The only way to have them set to non-executable by default is to edit the fstab for each drive, or switch them to fat32.

4
  • 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?
    – sastanin
    Dec 13, 2010 at 12:51
  • 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.
    – dkuntz2
    Dec 13, 2010 at 17:38
  • Choosing FAT32 or NTFS has nothing to do with setting the fmask. Dec 13, 2010 at 18:32
  • But by default files on fat32 drives are set to not executable. Hence kind of a solution.
    – dkuntz2
    Dec 13, 2010 at 23:20

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