systemd + Mounts with Special Characters
Since most of these blogs and posts and such don't mention this in a way that was adequate for me, I want to a few key points:
- Keys like
What=
and Where=
have literal values - no escapes
- Paths on the filesystem must be
systemd-escape
d
- the shell will interpret
\
, so SINGLE quote it to escape: 'my\x20'
- You MUST run
sudo systemctl daemon-reload
between name/content changes
sudo journalctl -xe ESCAPEME.mount
will give better logs that status
Example: /etc/systemd/system/ESCAPEME.mount
/etc/systemd/system/mnt-TrueNAS-TV\x20Shows.mount
:
[Unit]
Description=My CIFs Media Mounter
Requires=network-online.target
After=network-online.service
[Mount]
What=//192.168.1.200/TV Shows
Where=/mnt/TrueNAS/TV Shows
Options=username=my-user,password=my-secret
Type=cifs
[Install]
WantedBy=multi-user.target
Example: /etc/systemd/system/ESCAPEME.automount
/etc/systemd/system/mnt-TrueNAS-TV\x20Shows.automount
:
[Unit]
Description=My CIFs Media Automount
[Automount]
Where=/mnt/TrueNAS/TV Shows
[Install]
WantedBy=multi-user.target
More Info
See https://unix.stackexchange.com/questions/455094/auto-remount-cifs-share/740886#740886.
_netdev The filesystem resides on a device that requires network access (used to prevent the system from attempting to mount these filesystems until the network has been enabled on the system).