I have a Debian sid system (Wheezy) (and same for arch), without any desktop environment (and no Xorg at all).
I can mount my SD-cards, USB sticks, external HDD by label into a specified directory in
/media/ manually with
umount and the suitable entries in
/etc/fstab, or automatically at boot time, but this is compelling, to restrictive and not dynamic enough for my needs: if I want them to be mounted in
/media/<LABEL>, each device with a different
<LABEL> needs its own entry, and each
<LABEL> subdirectory 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 no matter how risky it is for the data)?
The ideal solution would:
- detect when a removable media is plugged-in (i.e. when added in
sdbx, ... by
- create a directory in
/media/according to its label (label of the removable media)
- mount it in the directory
RWmode (if it's filesystem supports that) with
flushoption (for a
- detect if the media has been unplugged
- if then, unmout it from the filesystem
- remove the corresponding directory from
(the devices should be mounted in synchronous mode oviously, to avoid any data loss when hot unplugged because of caching edit:
sync is way too much for
vfat removable media so
flush has been created as a compromise, less secure than
sync, but less risky according to the life-cycles of flash memories)
I found some info about
usbmount 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 ...