I have a Debian sid system (Wheezy) (and same question for arch as well), without any desktop environment (and no Xorg at all).
I can mount my SD-cards, USB sticks, external HDD manually with mount / umount with the suitable entries in /etc/fstab
but this is compelling, and to restrictive: if I want them to be mounted in /media/<LABEL>
each device with a different <LABEL>
needs its own entry, and each <LABEL>
directory needs to be created / removed manually in /media/
as well).
So, what is the best way to mount them automatically in /media/<LABEL>
at insertion (and to unmount them from the filesystem as soon as they are unplugged)?
The ideal solution would:
- detect when a removable media is plugged-in (added in
/dev/
assdax
,sdbx
, ... byudev
) - create a directory in
/media/
according to its label (label of the removable media) - mount it in the directory
/media/<LABEL>
in RW mode (if it's filesystem is supported) - detect if the media has been unplugged
- if then, unmout it from the filesystem
- remove the corresponding directory from
/media/
(the devices should be mounted in synchronous mode oviously, to avoid any data loss when hot unplugged because of caching)
I found some info about autofs
, HAL
, udisks
, udisks2
, etc., but it's unclear which one is deprecated or preferred, and anyway, I haven't figured out how to configure them easily on my system to do that, up to now ...
Minimalism, elegance, KISS, *nix-minded, no crazy unbearable XML policies files, and up-to-date highly appreciated.
edit: trying to make my question more clear