Ubuntu – How to set default permissions for automounted FAT drives in Ubuntu 9.10


I've got many FAT32 drives that I'd like to mount in Ubuntu such that they have permission mode 700 for directories and 600 for all other files. By default, they have 755 for all files, which is not particularly useful since almost no non-directories should be executable, and it screws up version control repos hosted on the drives.

"Back in the day" I would have had the drives listed in /etc/fstab with the umask/dmask I want and there was no such thing as a default. These days, drives automount under their volume names. Which is great, except now I have no idea how to set the default.

I have tried changing the /system/storage/default_options/vfat/mount_options gconf key with no apparently effect. It was 077 initially but the mounted drive reflected a default of 022; changing it and re-inserting the drives resulted in the files still having permission bits of 755.

Best Answer

Unfortunately there is no built-in means to do this. The "right way", the supported way, is setting an /etc/fstab line with the default mount options you want. This means your defaults must be set per-device, though you can use the partition label or UUID to avoid requiring a specific device path. In particular, this method seems to take place before the PolicyKit desktop authorization.

The Ubuntu forums, Launchpad and Gnome's bugzilla have many posts from users looking for the same functionality you're looking for, on both NTFS and FAT32. Ubuntu 9.10 and 10.04 provide the default automounting via a combination of DeviceKit-Disks, GVFS, and Nautilus.

DeviceKit-disks provides a FilesystemMount interface whose options argument appears to be the proper way to configure your mount options. But GVFS/Nautilus does not appear to provide any means, via the UI or a configuration file, to specify this option when automounting a USB key.

There are a couple of workarounds:

  • This Launchpad bug contains a user-provided patch that alters the DeviceKit-Disks defaults in a custom-built devicekit-disks package.

    On the plus side, this may be the easiest way to set your preferred defaults for all devices. The disadvantage is that you'll need to repatch again when the package is updated.

  • One Ubuntu Forums post proposes a device-specific workaround script:

    devkit-disks --unmount /dev/disk/by-uuid/0D3594370C618A2A
    devkit-disks --mount-options "dmask=000" --mount /dev/disk/by-uuid/0D3594370C618A2A

    This is also sub-optimal, since you'd have to keep this updated with specific devices. But it does avoid the authorization problem that the supported fstab solution can have.