How do I change the default permissions for automounted USB media?

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:

  • Related post on superuser
  • Related launchpad bug
  • Another related launchpad bug.

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


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.