NFS volume not mounting with systemd

Bug #1838464 reported by Michele Michielin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
Expired
Undecided
Unassigned

Bug Description

Hello,

I'm unable to mount NFS volume at boot time with systemd. Using Ubuntu 18.04.2 LTS.
I commented out /etc/fstab entry:
#192.168.1.103:/Multimedia/Music /mnt/nas/music/ nfs _netdev,auto,user,vers=3 0 0

I created "/etc/systemd/system/mnt-nas-music.mount":
[Unit]
Description=NAS volume - Music
After=network.target

[Mount]
What=192.168.1.103:/Multimedia/Music
Where=/mnt/nas/music/
Type=nfs
Options=_netdev,auto,user,nfsvers=3
TimeoutSec=10

[Install]
WantedBy=multi-user.target

I enabled it with "systemctl enable mnt-nas-music.mount" so that when I run "systemctl is-enabled mnt-nas-music.mount" I obtain:
enable

But I keep obtaining this error ("systemctl status mnt-nas-music.mount"):

 mnt-nas-music.mount - NAS volume - Music
   Loaded: loaded (/etc/systemd/system/mnt-nas-music.mount; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2019-07-30 21:23:42 CEST; 29min ago
    Where: /mnt/nas/music
     What: 192.168.1.103:/Multimedia/Music
  Process: 1530 ExecMount=/bin/mount 192.168.1.103:/Multimedia/Music /mnt/nas/music -t nfs -o _netdev,user,nfsvers=3 (code=exited, status=32)

lug 30 21:23:42 ubuntu-desktop systemd[1]: Mounting NAS volume - Music...
lug 30 21:23:42 ubuntu-desktop mount[1530]: mount.nfs: Network is unreachable
lug 30 21:23:42 ubuntu-desktop systemd[1]: mnt-nas-music.mount: Mount process exited, code=exited status=32
lug 30 21:23:42 ubuntu-desktop systemd[1]: mnt-nas-music.mount: Failed with result 'exit-code'.
lug 30 21:23:42 ubuntu-desktop systemd[1]: Failed to mount NAS volume - Music.

If I run "journalctl -b" I notice that the attempt to mount NFS volume happens before network is ready:
lug 30 21:23:42 ubuntu-desktop systemd[1]: Failed to mount NAS volume - Music.
lug 30 21:23:48 ubuntu-desktop NetworkManager[978]: <info> [1564514628.2750] device (enp2s0): Activation: successful, device activated.

I think this is a bug.
Thanks in advance
Michele

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https://wiki.ubuntu.com/Bugs/FindRightPackage. You might also ask for help in the #ubuntu-bugs irc channel on Freenode.

To change the source package that this bug is filed about visit https://bugs.launchpad.net/ubuntu/+bug/1838464/+editstatus and add the package name in the text box next to the word Package.

[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]

tags: added: bot-comment
Paul White (paulw2u)
affects: ubuntu → systemd (Ubuntu)
tags: added: bionic
Revision history for this message
Dan Streetman (ddstreet) wrote :

> After=network.target

you want to use network-online.target, not (only) network.target.

you also may want to use
Before=umount.target
Before=remote-fs.target

systemd will create an automatic mount unit for all mounts, so you can see what params it uses if you mount the NFS share manually (i.e. remove your mount unit file and mount from cmdline) and run systemctl show, e.g.:
$ systemctl show mnt-nas-music.mount

it also will dynamically create mount files for everything you have in /etc/fstab, at /run/systemd/generator/.

Is there a reason you want to replace the fstab entry with a systemd mount unit file?

Changed in systemd (Ubuntu):
status: New → Incomplete
Revision history for this message
Michele Michielin (michele-michielin) wrote :

Hello, thanks for your answer, I will test your suggestions as soon as possible.

Regarding your question about fstab, I forgot to mention that I've always mounted my NAS folder through fstab but after one ot the latest upgrade it stopped working.
I searched the internet for an alternative solution and I tried to do it manually.

Thanks again
Michele

Revision history for this message
Michele Michielin (michele-michielin) wrote :

Hello, I tried all of your suggestions but nothing changed.

First attempt: I tried to add the following lines to my unit file:

After=network.target network-online.target
Before=umount.target remote-fs.target

No success.

Second attempt: I removed my unit file, I mounted manually the folder (with "sudo mount -t nfs 192.168.1.103:/Multimedia/Music /mnt/nas/music/") and I noticed with "show mnt-nas-music.mount" that the options generated by systemd were different, so I changed my unit file this way:
______________________________________

[Unit]
Description=NAS volume - Music
Wants=network-online.target
WantedBy=multi-user.target
Conflicts=umount.target
Before=remote-fs.target multi-user.target umount.target
After=system.slice remote-fs-pre.target systemd-journald.socket network.target -.mount network-online.target

[Mount]
What=192.168.1.103:/Multimedia/Music
Where=/mnt/nas/music/
Type=nfs
Options=auto,user,nfsvers=3
TimeoutSec=10

[Install]
______________________________________

No success.

The error is always the same: "network is unreachable".

Please tell me if you need some other information.

Thanks for your help.

Michele

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for systemd (Ubuntu) because there has been no activity for 60 days.]

Changed in systemd (Ubuntu):
status: Incomplete → Expired
Revision history for this message
Dodiak (dodo-sk) wrote :

Hm, I think I have the same problem and the troublemaker is vers=3 in the mounting options. The remote FSs without vers=3 are mounted nicely. All the others are producing confusing errors as described above ...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.