I want every USB media (ext, ntfs, FAT…) inserted to be available with full read-writable to every user. Preferably under mnt and as group common.
( Ubuntu-MATE 21.04, though my issues actually date back even to Ubuntu-MATE 16.04...)
- I boot into my machine as user frank. When I mount an USB drive (FAT) it ends up under
/media/frank/4C8C-E4BC– just fine, as it should. When I switch to another user (keeping the first session open, not logging off, i.e.dm-tool switch-to-user lisa) I get
Unable to mount 16 GB Volume Device /dev/sda1 is already mounted at
/media/lisa/4C9C-xxxx
Making sense so far. But not what I want.
Sure, for individual drives I could change the mount location via gnome-disks or manually add a line to etc/fstab (which essentialy is what gnome-disks is doing). However I do not want to do this for each and every USB stick and SD card I posess...
Is there a better way for an all-user automount?
[ I understand/guess there's something called autofs handles the automatic mounting of USB sticks? But as far as I can tell, that's no part of my Ubuntu-MATE install... ]
And then there seems to be “udev-Rules”, is that, what I want? Apparently it's even an “inevitable” part of Ubuntu, as it is part of systemd (?)? There are rules on my machine under /etc/udev/rules.d although seemingly rather specific ones about brave and skype and signal...)
There's promising stuff MODE and GROUP and UDISKS_FILESYSTEM_SHARED but (provided this is the right approach) I can't set the ultimate puzzle pieces together. It should truly only apply to removable drives like USB sticks and memory cards, otherwise I get into deep trouble... this source mentions SUBSYSTEMS=="usb", that would be a good filter, if true...)
Is udev rulez the way?
If yes, can somebody set the puzzle pieces together? I am almost suspecting all I look for is a one-liner file in /etc/udev/rules.d.
addendum:
Not my main problem, but if it went away for the same reasons, I would be happy: Inserting a Windows Boot USB Stick (slightly more commplex, comes with an UEFI Boot FAT and a Windows Install NTSF partition) under the second user, I instantly get:
(and no, intense googling didn't get me anywhere) …switching back to first user frank (stick still inserted) I am welcomed by these authorization requests:
addendum:
Not a fix, but if those two users are essentially you, and the other one is not truly active (just switched-away from instead of logged-out) this is the quickest way before a trouble-free USB mount:
who -u
sudo kill <that other user's pid>


udevfor this purpose, but I have usedmountfor similar but simpler cases. So I am playing with a shellscript, than can do what you want, at least with Microsoft file systems. But 1. It needssudoor running asroot. You can allow using the shellscript ormkdirandmountwithout password viavisudo; 2. It is a bad idea to tamper with the permissions in a Linux file system, e.g.ext4. – sudodus Aug 04 '21 at 20:04chmod; 3. It should work to start a shellscript manually, but it is also possible (maybe viaudev) to watch for plugging in external devices; 4. Additinal shellscripts to unmount and clean up mountpoints should be easier to create. -- Are you interested of thismountway, or do you want to go theudevway? – sudodus Aug 04 '21 at 20:19/etc/fstabeither. Just for 'all USB drives that may be'. (iffstabhad some kind of wildcard-support to match USB-drives, my problem would be solved. But it doesn't.) Und Udev rules indeed also have aMODEattribute... – Frank N Aug 09 '21 at 10:19udevwell enough to help you with that. But mymountway can handle 'wild-card support'. However, you must initiate it somehow, viacronorudevor maybe some other way to watch for events. Do you want to see the script code? – sudodus Aug 09 '21 at 10:23