Systemd NFS Automount Not Working

Hi All,

I have the following .mount file:

Description=Music folder mounted via NFS from Tower unRaid.
DefaultDependencies=no
After=network.target

[Mount]
What=192.168.0.245:/mnt/disks/Expansion1/Music
Where=/mnt/Tower/Music
Type=nfs
Options=_netdev,auto

[Install]
WantedBy=multi-user.target

with corresponding .automount:

[[Unit]
Description=Automount music mount from unRaid tower
ConditionPathExists=/mnt/Tower/Music

[Automount]
Where=/mnt/Tower/Music
TimeoutIdleSec=10

[Install]
WantedBy=multi-user.target

As subject states, the mount isn’t working on reboot. If I manually mount, things go smoothly. System hangs for about 30-60 seconds since I added the two files to /etc/systemd/system folder.

Thoughts appreciated.

sample unit setttings

mount unit issues

In your mount unit add the missing [Unit] header

[Unit]

Remove the line

DefaultDependencies=no

automount unit issues

In your automount unit fix the spelling error [[

Unit settings

Ensure file naming are correct mnt-Tower-Music.{mount,automount} - must match the folder structure naming.

Disable the mount unit

sudo systemctl disable --now mnt-Tower-Music.mount

Enable the automount unit

sudo systemctl enable --now mnt-Tower-Music.automount

You should also remove this line from your mount unit since the automount unit is what you enable.

This also assumes you have set up /etc/exports on 192.168.0.245 correctly.
Also, don’t forget to start nfs-client.target.

[EDIT]
Resolved with above advice combined. Thanks all.

[/EDIT]

Wow I miss the days of good old init and fstab editing :wink:

Ok so some of the edits made were just typos (missed copy/paste). The [unit] errors caught weren’t errors, just fat fingers when I was copying to the forum post.

I’ve done the remaining changes other than

nfs-client.target

How do I go about doing this? Really appreciate it. 20 years of Linux and still learning a thing or two.

1 Like

You can still do that (use fstab), but not if you want to use the automount function (mounts first when access is requested).

sudo systemctl enable --now nfs-client.target
But now that I type that I get unsure if that is actually needed, it might get started anyway by other units. Hopefully someone will correct me if I am wrong with this.

Technically you can - by combining a a heap of options - but in my experience it is error prone - in fact the systemd mount topics was born out of my frustration with my nfs mounts in fstab.

Either they didn’t mount or the system was completely random hung because the network was not available …

I noticed that too when changing from samba to NFS for my network drive when mounting it directly with the mount unit at boot instead of using an automount unit.
I added Requisite=network-online.target in the mount unit, and have never had any problems since.
Might just be a coincidence and have nothing to do with it, but just in case, the option doesn’t hurt.

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.