Unable to mount volume, an operation is already pending (with multiple users)
This is untested but I did come across this page: automounting usb flash drives on linux with udev and pmount
The general idea is that you make a UDEV action that will automount using pmount instead. If you look in the comments there's a punmount -l
which will do a lazy unmount which should be safer.
excerpt
Here is a solution for automounting usb flash drives / memory sticks on linux using only udev and pmount.
add a file
automount.rules
in/etc/udev/rules.d
.put the following lines in it
# automounting usb flash drives # umask is used to allow every user to write on the stick # we use --sync in order to enable physical removing of mounted memory # sticks -- this is OK for fat-based sticks # I don't automount sda since in my system this is the internal hard # drive depending on your hardware config, usb sticks might be other # devices than sdb* ACTION=="add",KERNEL=="sdb*", RUN+="/usr/bin/pmount --sync --umask 000 %k" ACTION=="remove", KERNEL=="sdb*", RUN+="/usr/bin/pumount %k" ACTION=="add",KERNEL=="sdc*", RUN+="/usr/bin/pmount --sync --umask 000 %k" ACTION=="remove", KERNEL=="sdc*", RUN+="/usr/bin/pumount %k"
reload the udev rules:
udevadm control --reload-rules
NOTE: If you want to make this setup more tolerant to unmounting then you'll want to include the -l
for lazy unmounting to punmount
.
ACTION=="remove", KERNEL=="sda*", RUN+="/usr/bin/pumount -l %k"
From pumount
's man page:
-l, --lazy
Lazy unmount. Detach the filesystem from the filesystem hierarchy
now, and cleanup all references to the filesystem as soon as it is
not busy anymore. (Requires kernel 2.4.11 or later.)
IMPORTANT NOTES This option should not be used unless you really
know what you are doing, as chances are high that it will result
in data loss on the removable drive. Please run pumount manually
and wait until it finishes. In addition, pumount will not
luksClose a device which was unmounted lazily.
How can I turn off automount, and have it only try mounting when I click on it from within my file browser?
By using dconf-editor
to disable auto-mounting as described here: How to disable automount in nautilus's preferences.
Alternatively, run the following command:
gsettings set org.gnome.desktop.media-handling automount false