Isso não foi testado, mas eu encontrei esta página: montando drives flash USB no linux com udev e pmount
A idéia geral é que você faça uma ação UDEV que será montada automaticamente usando o pmount. Se você olhar nos comentários, há um punmount -l
que fará uma desmontagem que deve ser mais segura.
trecho
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
OBSERVAÇÃO: Se você quiser tornar essa configuração mais tolerante à desmontagem, convém incluir o -l
para a desmontagem lenta para punmount
.
ACTION=="remove", KERNEL=="sda*", RUN+="/usr/bin/pumount -l %k"
Da página de manual de pumount
:
-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.