Score:0

How to mount exFAT/FAT partitions as user without all files having the executable bit set in permissions?

in flag

Ubuntu 23.04 here, but should apply to almost every version.

I want to mount external drives via the user mount mechanisms in the system (is udev involved?), often over SSH with udisksctl mount -b /dev/sdX.

VFAT/exFAT drives show up with permissions 755, which is annoying since I don't want the executable bit set when I copy files. How can I force udisksctl (or is it udev under the hood?) to mount these drives with 644 permissions on all files?

My attempts with the /etc/udisks2/mount_options.conf file were not successful.

Setting of exfat_defaults=uid=$UID,gid=$GID,noexec didn't do the trick.

I restarted with sudo systemctl restart udisks2.service to make sure the changes were loaded.

Raffa avatar
jp flag
Udev is involved in making the block device available and then It's udisks2 that mounts filesystems and `udisksctl` is a command to manage it ... Those filesystems, however, don't support Unix/Linux permissions anyway.
emk2203 avatar
in flag
But they get mounted with permissions, and these defaults must be set somewhere. And the permissions stay when I copy to the internal drive. Yes, it's `udisks2`, but I was working under the assumption that `udisks2` might call `udev` for the ground work.
Raffa avatar
jp flag
"But they get mounted with permissions." ... Actually AFAIK no ... The permissions you see are for the mount point ... There might be a way to mask that in e.g. `/etc/fstab` so you might want to search for that.
muru avatar
us flag
`noexec` blocks execution of files irrespective of the mode, what you want are `fmask`/`dmask`/`umask`
emk2203 avatar
in flag
Masking in `/etc/fstab` is not useful since these are often changing removable disks which cannot be put in `/etc/fstab`. And the mount point `/media/user` is also generated on the fly by the system and has certain attributes set, where could I change these then? By the way, the attributes are `drwxr-x---+`, so not the same as an `a=x` attribute set after mounting VFAT/exFAT systems.
emk2203 avatar
in flag
@muru: Good find, but a `exfat_defaults=uid=$UID,gid=$GID,fmask=0644` line in `/etc/udisks2/mount_options.conf` and restart of service still gives the same result: all files have attribute `a=x`.
muru avatar
us flag
It's a mask, not the desired mode. Try something like `0133`
Marco avatar
br flag
The x-bit usually is set for showing one of the attributes of a FAT file (archive, hidden or read-only) which are not known by Posix.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.