Comment 75 for bug 1590799

Revision history for this message
Maarten Jacobs (maarten256) wrote :

As it turns out, I'd not subscribed to this bug so I didn't get comments after I posted mine. I had to refer back to my own comment to figure out the solution since my NFS server apparently broke earlier this week.

An update to nfs-common (I think that's the package that installs the service files) was pushed out and overwrote the "fix" I'd put in earlier.

A more complete fix (after some trial and error) was to create the "override.conf" files for nfs-server and nfs-mountd using:

sudo systemctl edit nfs-server (same for nfs-mountd).

I copy/pasted the baseline service definitions into the override files and added my own tweaks. With that, the override files I am currently running with are as follows (output from systemctl cat nfs-server and nfs-mountd):

-------
# /etc/systemd/system/nfs-server.service.d/override.conf
[Unit]
Description=NFS server and services
DefaultDependencies=no
Requires= network.target proc-fs-nfsd.mount
Requires= nfs-mountd.service
Wants=rpcbind.socket
Wants=nfs-idmapd.service

After= local-fs.target
After= network.target proc-fs-nfsd.mount rpcbind.socket nfs-mountd.service
After= nfs-idmapd.service rpc-statd.service
Before= rpc-statd-notify.service

# GSS services dependencies and ordering
Wants=auth-rpcgss-module.service
After=rpc-gssd.service rpc-svcgssd.service

# start/stop server before/after client
Before=remote-fs-pre.target

Wants=nfs-config.service
After=nfs-config.service

BindsTo=rpcbind.service
After=rpcbind.service

[Service]
EnvironmentFile=-/run/sysconfig/nfs-utils

ExecStart=
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/usr/sbin/exportfs -r
ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS
ExecStop=/usr/sbin/rpc.nfsd 0
ExecStopPost=/usr/sbin/exportfs -au
ExecStopPost=/usr/sbin/exportfs -f

ExecReload=/usr/sbin/exportfs -r

[Install]
WantedBy=multi-user.target
------

Note the addition of:
   BindsTo=rpcbind.service
   After=rpcbind.service
   ExecStart=

------
# /etc/systemd/system/nfs-mountd.service.d/override.conf
[Unit]
Description=NFS Mount Daemon
DefaultDependencies=no
Requires=proc-fs-nfsd.mount
After=proc-fs-nfsd.mount
After=network.target local-fs.target
After=rpcbind.socket
BindsTo=nfs-server.service

Wants=nfs-config.service rpcbind.service
After=nfs-config.service rpcbind.service

[Service]
EnvironmentFile=-/run/sysconfig/nfs-utils
Type=forking
ExecStart=
ExecStart=/usr/sbin/rpc.mountd $RPCMOUNTDARGS
------

Note the addition of "rpcbind.service" on the "Wants" and "After" lines, as well as the "ExecStart=".

It took me a bit to figure out the "ExecStart=" directives were required. As I found out, the ExecStart directive is additive, so the "ExecStart=" directive is required to "clear out" the directive set in the baseline service files. (In other words, the baseline service file is read before override.conf is read).

This appears to work for me on Ubuntu 16.04.06. I am not in a position to verify these tweaks work on later versions of Ubuntu.