Mounting removable storage devices in Gnome

Whenever I attach a removable storage device like a USB memory stick to my computer running a Gnome desktop, it gets scanned for partitions and file systems, which are then mounted automatically. That’s very convenient, as file systems like exfat that do not have a notion of user or group identities are mounted with the proper uid= and gid= options for the user running the desktop. However, I have been unable so far to figure out a way of setting any mount options of my own. For example, I want to mount a USB flash memory stick with -o sync to avoid using the page cache.

Any hints, anyone? Of course, creating an entry in /etc/fstab is out of the question, because I want to keep the uid/gid part.

disks should let you do that.

“Edit Mount Options” should do what you want

No, it doesn’t. Using disks creates an entry in /etc/fstab, the very thing I want to avoid for the reason given above.

Mount options that udisks (system daemon used by GNOME for mounting) can be configured in /etc/udisks2/mount_options.conf (if the config file doesn’t exist, example config should be available in mount_options.conf.example). See the documentation for more details, but short version is that you can specify default mount options for your device like this:

[/dev/disk/by-uuid/18afd8f0-0d86-4d96-8de0-5f92d2ee9800]
vfat_defaults=uid=$UID,gid=$GID,sync

You need to use some persistent path to your device so either /dev/disk/by-uuid or /dev/disk/by-id and then just add the mount options you want to be used with that specific device depending on the filesystem (the example is for FAT).

That’s the way to go, obviously. Thanks!