You are not logged in.
Pages: 1
I found the wiki about udev pretty confusing and would need help.
I moved my entire Music library to an external HD. I would like to "mount --bind /run/media/user/drivename/Music ~/Music" automatically whenever I plug the external HD to my laptop. There is quite a lot of other folders on the HD which I do want to access normally, so it would be: 1. mount the external HD normally and then 2. mount the Music folder.
Is there any clean way to do this?
Offline
Maybe to clarify this: RIght after the GNOME automount of the external HD, I would love to have the command "mount --bind /run/media/user/drivename/Music ~/Music" entered. This cannot be so hard, I simply don't find the solution...
Last edited by macaco (2018-06-14 18:00:53)
Offline
Use a service file:
Requires=media-externalHD.mount
After=media-externalHD.mount
Assuming your mount point is /media/
Offline
Ask your local hackerspace. As nautilus doesn't figure --bind mounting too well we had to do some workaround. Here are the results:
~/.local/bin/bindmounter.sh
#!/bin/zsh
## (c) Bernhard Tittelbach, 2018, GPLv3
local mdir="$HOME/Música"
local vdir="$HOME/Vídeos"
local extdisk_mntpath="/run/media/$USER/fatCrypt"
local inotifywait=/usr/bin/inotifywait
local i=10
while ! mount | grep -q "$extdisk_mntpath"; do
sleep 0.1
[[ $((i--)) -eq 0 ]] && {echo "Disk was not mounted where expected after waiting, doing nothing"; exit 0}
done
[[ -x $inotifywait ]] || {echo "ERROR: inotify-tools not installed"; exit 1}
mount | grep -q "$extdisk_mntpath" || {echo "Disk not mounted where expected, doing nothing"; exit 0}
mount | grep -q "$mdir" || mount "$mdir"
mount | grep -q "$vdir" || mount "$vdir"
local monfifo=$(mktemp -u)
mkfifo $monfifo
dbus-monitor --system "type='signal', interface=org.freedesktop.DBus.ObjectManager, member=InterfacesAdded, path=/org/freedesktop/UDisks2" > $monfifo &
local monitorpid=$?
trap "kill $monitorpid; rm $monfifo" EXIT
while read LINE < $monfifo; do
#if $inotifywait -q -e unmount "${extdisk_mntpath}/."; then
if [[ $LINE == *filesystem-unmount* ]]; then
if ! mount | grep -q "$extdisk_mntpath"; then
umount -l "$mdir" "$vdir"
exit 0
fi
fi
done
~/.local/share/systemd/user/bindmount.path
[Unit]
Description=Run Script on mount
Unit=bindmount.service
[Path]
DirectoryNotEmpty=/run/media/berni/fatCrypt
[Install]
WantedBy=default.target
~/.local/share/systemd/user/bindmount.service
[Unit]
Description=Bindmount Music und Video directories
[Service]
ExecStart=/home/berni/.local/bin/bindmount.sh
PassEnvironment=HOME USER
Type=simple
RemainAfterExit=false
Restart=never
[Install]
It took us some time to come up with that. Feel free to use and share
Offline
Pages: 1