9

tl;dr:

How do I make gnome automount USB devices with permissions so that everyone in the group can access them instead of just one user that is logged in at the time the USB storage is plugged in?

(Here the group is called confus and the users narur and confus are both in that group. Only narur was logged in, at time of USB plug in so only narur can access the USB device - even after a sudo chmod g+rw. How do I change that?)


Details:

I run a media server at my home. It is connected to a projector as only monitor. Form time to time I like to plug in a USB drive to copy stuff from the server to said drive. The drive gets auto-mounted by the usual gnome shenanigans. Obviously I don't want to turn on the projector (take a while and is not good on the lamp). So I login to the server over ssh and do the copy over terminal from another PC.

Problem is, the USB drive gets mounted under a different user than the user I log in as via ssh. My ssh user doesn't have the rights to open the mount point chosen by gnome although it is in the same group. For clarification see this terminal session:

confus@conserve:/media$ id
uid=1000(confus) gid=1000(confus) groups=4(adm),8(mail),20(dialout),24(cdrom),46(plugdev),113(lpadmin),114(sambashare),122(admin),126(debian-transmission),135(debian-tor),1000(confus)

confus@conserve:/media$ ll
total 28
lrwxrwxrwx  1 root   root      6 Mar  8  2009 cdrom -> cdrom0
drwx------  1 narur  confus 4096 Oct  8 16:53 contemplate     # <-- USB drive
drwxr-xr-x  2 root   root   4096 May  3  2010 iso
drwxr-xr-x  2 confus confus 4096 Dec  8  2009 usb1

confus@conserve:/media$ sudo chmod -R ug+rwX 4009-D44F/       # <-- Doesn't do anything
[sudo] password for confus: 

confus@conserve:/media$ ll
total 28
lrwxrwxrwx  1 root   root      6 Mar  8  2009 cdrom -> cdrom0
drwx------  1 narur  confus 4096 Oct  8 16:53 contemplate    # <-- No change after chmod
drwxr-xr-x  2 root   root   4096 May  3  2010 iso
drwxr-xr-x  2 confus confus 4096 Dec  8  2009 usb1

My ssh user is "confus" while the disk is mounted for the user "narur". Obviously a simple chmod doesn't do since its a mount point. The problem exists for every USB storage device.

I know I could write a udev rule and I know that device based solutions exists. But there should be an easier solution to this problem, that's native to gvfs.

Update:

Nothing has changed since 2009. This is embarrassing. There should be an easy work around for this problem at least.

6
  • It's not the full answer, but you're looking for autofs. There's a decent manual/descritpion here: wiki.debian.org/AutoFs . The GID mount option is what you're looking for. Oct 25, 2012 at 13:32
  • If I'm not mistaking that's also a by-device solution, isn't it? One has to configure each individual device. I want my solution to apply to all auto mounted drives since various owners might want to copy files on their respective drives.
    – con-f-use
    Oct 25, 2012 at 13:52
  • Usually it would be by device. You could use fuzzy udev rules to run mount scripts if you want it to be generic. Oct 25, 2012 at 13:55
  • So no need for autofs then... ;-) I'd still prefer a solution inherent to gvfs or gnome. There seem to be quiet a lot bug reports on this but nothing changes since 2009
    – con-f-use
    Oct 25, 2012 at 14:01
  • 1
    This is a limitation with udisks v1, for anyone coming here, the new udisks2 (Ubuntu 13.04 or later) added ID_FS_USAGE & UDISKS_FILESYSTEM_SHARED that should resolve the problem of shared volumes mounting. Reference: askubuntu.com/a/276670/26246
    – user.dz
    Sep 16, 2015 at 14:53

1 Answer 1

3

I guess your USB drive is formatted with VFAT/FAT32. This file format does not support execute permissions which is why chmod +x fails.

[Edit] Ok, had a bit of a play and search on the net. Lots of 'solutions' suggest that you should change /etc/fstab. This just seems clunky to me, what do you do? change fstab every time you encounter a new USB flash drive???

My solution:

$ sudo vi /etc/udev/rules.d/90-usb-disks.rules

Add the lines:

# UDEV Rules to change the permission of USB disks

#

KERNEL=="sd*[0-9]", ATTR{removable}=="1", ENV{ID_BUS}=="usb", MODE="0022"

$ sudo /etc/init.d/udev restart

Then try inserting a usb drive. There is probably an attribute that you can check for to ensure it's a FAT formatted drive if you wanted to be more specific.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .