When I plug in a USB drive it is automatically mounted on /run/media/user/fslabel
. This is done, I guess by some udev/dbus/thunar/nautilus/gvfs or other system, and I find this convenient and do not want to revert to manual mounting by root. However, I have a problem with the default mount options: vfat drives are mounted such that the executable flag ist set on all regular files. This is a nuissance and a security problem and I wish to disable it.
How do I set system-wide options for mounting, like using the noexec
flag for all vfat
partitions and disabling mounting of ext4
partitions by user-space programs/daemons?
A few years ago I tried something very time-consuming on a different system, like editing some udev
or dbus
rules (quite apparently not files designed to be edited by hand), which was a great effort due to lack of proper documentation and great variation between distros. Is this the intended and only way? If so, could someone please tell me what to change where?
I am using Arch Linux, CentOS and openSUSE with the XFCE Desktop. Automount may be performed by one of nautilus, thunar or dolphin, running in the background (or possibly, a service started by these?!). I am not sure because it happens in the background.
Best Answer
External media/drives mounting is handled by
udisks2
on most modern distros. I don't think there's any trivial way to change the default mount options as they are hard-coded (seeFSMountOptions
inudiskslinuxfilesystem.c
) that is, they're not configurable (at least not yet1). Your options are quite limited: unmount the partition and remount it with different mount options (unless you're willing to patch the source code or write your own automount tool).As to your other question:
You could use a
udev
rule to ignore all USB thumbdrive partitions exceptvfat
ones. Create a new rule file e.g./usr/lib/udev/rules.d/90-ignore-nonvfat.rules
with the following content:(replace
UDISKS_IGNORE
withUDISKS_PRESENTATION_HIDE
if your distro uses udisks1).1: see FreeDesktop ML for a proposed patch (and a long discussion).