https://oguya.ch/posts/2015-09-01-systemd-mount-partition/ https://unix.stackexchange.com/questions/246935/set-systemd-service-to-execute-after-fstab-mount
This started because the fuse mounts on /etc/fstab didn´t process right the "nofail" options and the init of the server will fail if external drive are not present. So I need some alternative command to "dependable" automount some folders or partitions.
systemctl list-units | grep '/media/Elements' | awk '{ print $1 }'
In my case that command returns:
media-Elements.mount
first, install fuse filesystem:
sudo apt-get install bindfs
I want to convert:
/media/Elements/data/mariadb /media/data-mariadb fuse.bindfs force-user=mysql,force-group=mysql,perms=0660:ug+D 0 0
the dash in the name for data-mariadb was a major mistake that caused many errors, but at this point this is how to correct spell names:
systemd-escape -p --suffix=mount "/media/data-mariadb/"
returns "media-data\x2dmariadb.mount" as filename, but that name must be escaped because of filename rules, so:
So, let's start by:
sudo nano /etc/systemd/system/media-data\\x2dmariadb.mount
and fill with:
[Unit]
Description=Mount data directory with permission
Requires=media-Elements.mount
After=media-Elements.mount
[Mount]
What=/media/Elements/data/mariadb
Where=/media/data-mariadb
Type=fuse.bindfs
Options=force-user=mysql,force-group=mysql,perms=0660:ug+D
[Install]
WantedBy=multi-user.target
Start and Enable the unit to start automatically during boot.
$ sudo systemctl daemon-reload
$ sudo systemctl start media-data\\x2dmariadb.mount
$ sudo systemctl enable media-data\\x2dmariadb.mount
You propably noted that I'm mounting a mariadb data partition, for that reason is recomended to edit that service to depend on the mounted data drive https://blog.zencoffee.org/2016/06/customizing-unit-files-systemd/