You need quite a lot of services and some pseudo file systems mounted for nfs to work properly. When I switched to systemd there weren't any service files so I wrote my own. Took me a while, since it was a bit of a hassle to find out the right order and what I actually need. This is my setup for nfsv4:
proc-fs-nfsd.mount:
Code:
[Unit]
Description=/proc/fs/nfsd
Before=nfs.target
Before=rpc.nfsd.service
[Mount]
What=nfsd
Where=/proc/fs/nfsd
Type=nfsd
Options=nodev,noexec,nosuid
[Install]
WantedBy=nfs.target
var-lib-nfs-rpc_pipefs.mount:
Code:
[Unit]
Description=rpc_pipefs
Before=nfs.target
Before=remote-fs-pre.target
[Mount]
What=rpc_pipefs
Where=/var/lib/nfs/rpc_pipefs
Type=rpc_pipefs
[Install]
WantedBy=nfs.target
rpcbind.service:
Code:
[Unit]
Description=NFS port mapping server
Before=nfs.target
Before=remote-fs-pre.target
[Service]
EnvironmentFile=/etc/conf.d/rpcbind
ExecStart=/sbin/rpcbind $RPCBIND_OPTS
Type=forking
[Install]
WantedBy=nfs.target
rpc.idmapd.service:
Code:
[Unit]
Description=NFSv4 ID - Name Mapper
Wants=rpcbind.service
Wants=var-lib-nfs-rpc_pipefs.mount
Wants=proc-fs-nfsd.mount
After=proc-fs-nfsd.mount
Before=nfs.target
Before=remote-fs-pre.target
[Service]
EnvironmentFile=/etc/conf.d/nfs
ExecStart=/usr/sbin/rpc.idmapd -f $OPTS_RPC_IDMAPD
[Install]
WantedBy=nfs.target
rpc.mountd.service:
Code:
[Unit]
Description=RPC mountd
Wants=rpcbind.service
After=rpcbind.service
After=rpc.svcgssd.service
After=rpc.idmapd.service
Before=nfs.target
[Service]
EnvironmentFile=/etc/conf.d/nfs
ExecStart=/usr/sbin/rpc.mountd --foreground $OPTS_RPC_MOUNTD
[Install]
WantedBy=nfs.target
rpc.statd.service:
Code:
[Unit]
Description=NFS status daemon
Wants=rpcbind.service
After=rpc.svcgssd.service
After=rpc.idmapd.service
After=rpc.mountd.service
Before=rpc.nfsd.service
Before=nfs.target
[Service]
EnvironmentFile=/etc/conf.d/nfs
ExecStart=/sbin/rpc.statd --no-notify -F $OPTS_RPC_STATD
sm-notify.service:
Code:
[Unit]
Description=NFS sm-notify
Wants=rpc.statd.service
Before=nfs.target
Before=remote-fs-pre.target
[Service]
EnvironmentFile=/etc/conf.d/nfs
ExecStart=/usr/sbin/sm-notify -d $OPTS_SMNOTIFY
Type=oneshot
[Install]
WantedBy=nfs.target
rpc.gssd.service:
Code:
[Unit]
Description=NFS rpcsec_gss daemon
Wants=rpcbind.service
Wants=var-lib-nfs-rpc_pipefs.mount
After=var-lib-nfs-rpc_pipefs.mount
Before=nfs.target
Before=remote-fs-pre.target
# shutdown while sleeping, to re-authenticate with kerberos after resume
Conflicts=sleep.target
[Service]
EnvironmentFile=/etc/conf.d/nfs
ExecStart=/usr/sbin/rpc.gssd -f $OPTS_RPC_GSSD
Restart=on-failure
[Install]
WantedBy=nfs.target
rpc.svcgssd.service:
Code:
[Unit]
Description=NFS rpcsec_gss server daemon
Wants=rpcbind.service
Wants=proc-fs-nfsd.mount
After=proc-fs-nfsd.mount
Before=nfs.target
[Service]
EnvironmentFile=/etc/conf.d/nfs
ExecStart=/usr/sbin/rpc.svcgssd -f ${OPTS_RPC_SCVGSSD}
Restart=on-failure
[Install]
WantedBy=nfs.target
rpc.nfsd.service:
Code:
[Unit]
Description=NFS server
Wants=rpcbind.service
Wants=rpc.statd.service
Wants=rpc.mountd.service
After=rpcbind.service
After=rpc.statd.service
After=rpc.svcgssd.service
After=rpc.idmapd.service
Before=nfs.target
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/nfs
ExecStart=/usr/sbin/rpc.nfsd ${OPTS_RPC_NFSD}
ExecStop=/usr/sbin/rpc.nfsd 0
[Install]
WantedBy=nfs.target
exportfs.service:
Code:
[Unit]
Description=NFS server exports
Wants=rpcbind.service
Wants=rpc.statd.service
After=rpc.mountd.service
After=rpc.statd.service
Before=nfs.target
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/nfs
ExecStart=/usr/sbin/exportfs -r
ExecStop=/usr/sbin/exportfs -ua
ExecReload=/usr/sbin/exportfs -r
[Install]
WantedBy=nfs.target
nfs.target:
Code:
[Unit]
Description=NFS services
[Install]
WantedBy=multi-user.target
The rpc.[svc]gssd services are only needed if you use nfsv4 with kerberos authentication. Enable rpc.gssd on the client and rpc.svcgssd on the server.
The rpc.mountd and rpc.statd, as well als sm-notify services are only necessary if you are using nfsv3 shared. Enable the first two on the server if you export nfsv3 shares, and sm-notify on the client.
To make it a little easier, these are the services you need to enable on the server:
Code:
systemctl enable var-lib-nfs-rpc_pipefs.mount
systemctl enable proc-fs-nfsd.mount
systemctl enable rpcbind.service
systemctl enable rpc.idmapd.service
systemctl enable rpc.nfsd.service
systemctl enable exportfs.service
# for NFSv3 only:
systemctl enable rpc.mountd.service
systemctl enable rpc.statd.service
# for NFSv4 kerberos auth only:
systemctl enable rpc.svcgssd.service
# finally, enable nfs.target to start services at boot:
systemctl enable nfs.target
on the client:
Code:
systemctl enable rpcbind.service
systemctl enable var-lib-nfs-rpc_pipefs.mount
systemctl enable rpc.idmapd.service
# for nfsv3 only:
systemctl enable sm-notify.service
# for nfsv4 kerberos auth only:
systemctl enable rpc.gssd.service
# finally, enable nfs.target to start services at boot:
systemctl enable nfs.target
Of course you need to add a "After=remote-fs-pre.target" in the [unit] section to any .mount unit on the client that should mount an nfs share.
Hope those files can help you.