# [solved]How to set mount options for automounted USB drives?

## kimmie

Does anyone know how to set mount options for particular removable media in the current udisks/gnome environment?

I can put a UUID line in the fstab, but then I lose the automount.

I can't find a description of how to do this anywhere. Do I have to write udev rules? policykit thingamajiggerits? I'm lost. I'm kind of hoping some bright spark has found a way of putting this into the fstab, it's not fair on users to have to write rules...Last edited by kimmie on Sun Aug 07, 2011 11:10 pm; edited 1 time in total

----------

## gringo

i have been wondering about the same for a while but havent found anything reliable other than udev rules, which is a royal pita imo.

As you say, writing your own rules wll probably work but i just dont want to start messing with udev because of this.

Anyways, for the rules solutions, have a look to this f.ex. -> https://wiki.archlinux.org/index.php/Udev#Auto_mounting_USB_devices

or for a fstab workaround http://forums.fedoraforum.org/showpost.php?s=e4382638f5d997eff9c3a4149b191dc3&p=1282887&postcount=5

cheers

----------

## kimmie

I'm using a similar fstab line, but using UUID= and not mounting in /media, maybe that's why automount doesn't work with it. But that Archlinux doco is what I was looking for, I didn't find anything that targeted and gave up. Thanks, I'll post back if I get something going.

----------

## kimmie

Well, I've got some sort of workaround, it'll have to do for now. Background: as of August 2011, gentoo stable, gnome2... 

gnome-disk-utility (gdu) + nautilus displays a desktop (and a computer:///) icon for anything (auto)mounted in /media.

having an fstab entry normally prevents automounting, and display of the icon.

UNLESS the fstab entry nominates a mount point in /media (eg. /media/test), in which case the desktop icon is displayedwhether or not the device is mounted and whether or not the mount point exists. When such an fstab entry is present:

If the mount point is created manually (ie. mkdir /media/test), then when the device is inserted it gets automounted with the fstab mount options. Also (surprise!), an additional desktop icon gets created! 

If the mount point is not created manually, then when the device is inserted the automount fails with a message (eg. /media/test does not exist).

When the automounted device is removed, the mountpoint directory is deleted, even if it had been created manually.

 To me, this indicates that the special case of fstab entry with mountpoint in /media isn't catered for properly in the code. In any case this behaviour isn't of any practical use.

The only workaround I can find is to ignore gdu, put an entry in /etc/fstab, and mount/unmount in custom rules, using a mountpoint outside /media. I tried hard to get a solution where the mount was shown in the desktop, but I can't get around the two icons problem... gdu needs fixing. It would also be nicer to omit the fstab entry and have all the info here, but without the fstab entry the user can't unmount from the command line.

```
# /etc/udev/rules.d/81-custom-udisks.rules

#

# This is a workaround for being unable to specify mount options for removable drives

# using udisks/gdu/nautilus. It gives automounting in /mnt by label. The device will

# be unmounted when removed. Matching /etc/fstab lines are required, including

# users as a mount option, eg.:

#   LABEL=carkeys  /mnt/carkeys  vfat \

#                  noauto,users,uid=fred,gid=fred,umask=077,flush,showexec,utf8  0 0 

# Note that ID_FS_LABEL has been supplied by /lib??/udev/rules.d/80-udisks.rules

# You can see what's available by running 'udisks --monitor-detail'

# The USB dongle I keep on my car keys

ENV{ID_FS_LABEL}=="carkeys", GOTO="custom_local_udisks_mount"   

GOTO="custom_local_udisks_end"

    

LABEL="custom_local_udisks_mount"

ENV{mp}="/mnt/%E{ID_FS_LABEL}"

ACTION=="add", RUN+="/bin/mkdir -p %E{mp}", RUN+="/bin/mount %E{mp}"

ACTION=="remove", RUN+="/bin/umount -l %E{mp}", RUN+="/bin/rmdir %E{mp}"

LABEL="custom_local_udisks_end"
```

----------

