You are not logged in.

#1 2016-08-15 23:57:46

hansh64
Member
Registered: 2016-08-15
Posts: 3

Auto mount and un-mount any USB pendrive to one specific directory

Hi all,

I would like to automatically mount a USB pendrive of any vendor, type and file-system to a specific directory and automatically umount when pendrive is removed. Now I am using systemd and fstab, in this case:

/dev/sdd1      /data/Music/USB      auto            nofail, x-systemd.automount, x-systemd.device-timeout=1 (and some other options) 0   0

This makes files on the USB pendrive accessible in the /data/Music/USB directory when an USB drive is inserted. However, when the USB drive is removed, the mount directory becomes empty but some apps (in my case mpd) believes these files are still around. I really need to umount this directory on USB removal.

Any suggestions?

Thanks!

Offline

#2 2016-08-16 12:38:55

ukhippo
Member
From: Non-paged pool
Registered: 2014-02-21
Posts: 366

Re: Auto mount and un-mount any USB pendrive to one specific directory

Try a udev rule which runs “systemctl stop data-Music-USB.mount” on a remove action.
It may not solve your problem 100% — e.g. a program may have cached the filenames.

Offline

Board footer

Powered by FluxBB