I have ongoing headaches with systemd. My mount, automount, and most recent error are below.
Summary: Two separate problems.
(1) Sometimes mounts fail on boot and I have to manually mount by doing
sudo systemctl enable --now mnt-Tower-Media.mount
(2) Sometimes the above manual command works, other times, it doesn’t and I get this error:
/etc/systemd/system sudo systemctl enable --now mnt-Tower-Media.mount 1 ✘
The unit files have no installation config (WantedBy=, RequiredBy=, UpheldBy=,
Also=, or Alias= settings in the [Install] section, and DefaultInstance= for
template units). This means they are not meant to be enabled or disabled using systemctl.
Possible reasons for having these kinds of units are:
• A unit may be statically enabled by being symlinked from another unit's
.wants/, .requires/, or .upholds/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
instance name specified.
Here’s an example of my .automount
[Unit]
Description=Automount Media mount from unRaid tower
ConditionPathExists=/mnt/Tower/Media
[Automount]
Where=/mnt/Tower/Media
TimeoutIdleSec=20
[Install]
WantedBy=multi-user.target
Here’s the corresponding mount
GNU nano 8.2 mnt-Tower-Media.mount
[Unit]
Description=Media folder mounted via NFS from Tower unRaid.
After=network.target
[Mount]
What=192.168.0.245:/mnt/user/Media
Where=/mnt/Tower/Media
Type=nfs
Options=_netdev,auto
Why the inconsistent behavior? I’ll test your solution but I’m curious why it works about 90% of the time but then spits out errors otherwise. That to me, suggests a bug.
This didn’t resolve the issue. Ongoing inconsistent behavior with it automounting about 90% of the time. The .mount isn’t enabled, the .automount is. Same problems.
I switched to mount/automount units because I experienced difficulties getting the systemd options in fstab to work - since then I have not issues with mounting my network shares.
If you cannot get it to work - there may be other underlying issues …
Work out what that is - now that is a completely different task.
Troubleshooting path
check your mount unit
test the mount unit manually
sudo systemctl start <mount-path.mount>
when manual start populates the mount path - stop the unit
sudo systemctl stop <mount-path.mount>
verify your automount unit
test the mount unit manually
sudo systemctl start <mount-path.automount>
list the content of the mount path
ls </mount/path>
when the mount path is populated you can enable the automount unit
$ systemctl status a-nfs-data.mount
○ a-nfs-data.mount - NAS NFS data share
Loaded: loaded (/etc/systemd/system/a-nfs-data.mount; disabled; preset: disabled)
Active: inactive (dead) since Tue 2024-12-17 06:05:11 CET; 1min 40s ago
Duration: 10.451s
Invocation: 92b0311609b94aa99118d69b9671be6a
TriggeredBy: ● a-nfs-data.automount
Where: /a/nfs/data
What: nas.net.nix.dk:/volume1/data
Mem peak: 2.4M
CPU: 25ms
dec 17 06:05:00 tiger systemd[1]: Mounting NAS NFS data share...
dec 17 06:05:00 tiger systemd[1]: Mounted NAS NFS data share.
dec 17 06:05:11 tiger systemd[1]: Unmounting NAS NFS data share...
dec 17 06:05:11 tiger systemd[1]: a-nfs-data.mount: Deactivated successfully.
dec 17 06:05:11 tiger systemd[1]: Unmounted NAS NFS data share.
status for automount unit
$ systemctl status a-nfs-data.automount --no-pager
● a-nfs-data.automount - NAS NFS data share
Loaded: loaded (/etc/systemd/system/a-nfs-data.automount; enabled; preset: disabled)
Active: active (waiting) since Tue 2024-12-17 06:04:52 CET; 2min 24s ago
Invocation: 0de80f5642e043dda1a5c10cb958ee19
Triggers: ● a-nfs-data.mount
Where: /a/nfs/data
dec 17 06:04:52 tiger systemd[1]: Set up automount NAS NFS data share.
dec 17 06:05:00 tiger systemd[1]: a-nfs-data.automount: Got automount request for /a/nfs/data, trigger…75 (ls)
Hint: Some lines were ellipsized, use -l to show in full.
listing the share
The content of /a/nfs/data is listed using mount on access via the automount unit.
I’ll work through these but it appears like manually starting the automount is working. The real issue is that on reboot, it automounts only about . . . 50% of the time which makes a few automated tasks harder to run (I have to check to see if mount exists before running certain jobs).
#!/usr/bin/bash
# variables
#SMB: 445
#NFS : 2049
#SSH : 22
PORT=2049
HOST=ip.x.y.z
RESULT=$(nmap $HOST -Pn -p $PORT | grep -e 'open')
# use nmap to check the host for service on port
if [[ -z "${RESULT}" ]] ; then
echo "host ${HOST}:${PORT} is down"
# exit with error code
exit 1
fi
echo
echo "Host: $HOST has ${RESULT}"
echo
echo "do important stuff"
echo ""
echo "browsing $HOST:/volume1/data"
echo "mounted using '/etc/systemd/system/a-nfs-data.automount' unit"
echo "-= content of share =-"
echo ls /a/nfs/data | head -n 4
# shellcheck disable=SC2012
ls /a/nfs/data | head -n 4
The result from the script
09:11:33 ○ [fh@tiger] ~/temp
$ bash test.sh
2049/tcp open nfs
do important stuff
browsing nas.net.nix.dk:/volume1/data
mounted using '/etc/systemd/system/a-nfs-data.automount' unit
ls /a/nfs/data
-= content of share =-
1.mp4
2.mp4
3.mp4
4.mp4