man rpc.statd For NFS version 2 [RFC1094] and NFS version 3 [RFC1813], the Network Status Monitor protocol (or NSM for short) is used to notify NFS peers of reboots. There is no need for rpc.statd on full NFS4 installation, however it is list as need in /etc/init.d/nfs : need portmap rpc.statd ${myneed} ${NFS_NEEDED_SERVICES} If I removed it from the "need" list (or just kill the daemon) NFS still work fine. Reproducible: Always Expected Results: It should be possible to remove rpc.statd (USE flag, configuration variable…). Running rpc.statd do no harm, it just has nothing to do… This bug is not important (there is no loss of function).
Maybe we should do this in the same way Debian does. Instead of $NFS_NEEDED_SERVICES they use the variables $NEED_STATD and $NEED_IDMAPD, where unset means "yes". If $NEED_STATD is set to "no" rpc.statd, rpc.mountd, rpcbind, and sm-notify will be skipped. There is also the variable $NEED_GSSD where unset means autodetect.
Actually, from my tests rpc.mountd is also needed on pure NFSv4 server. I look for some explanation and found : https://www.ietf.org/mail-archive/web/nfsv4/current/msg06122.html > On some implementations it also handles the exporting file systems, by > maintaining a database of what is exported and informing the kernel of these > exports via a system call. I think it's the case on Gentoo… but I am not sure. My clients can't mount nfsv4 shares, when rpc.mountd is not launch on the server. rpc.mountd run with "-N 2 -N 3" which disable nfs 2 & 3. It doesn't listen on any network port. In `man rpc.mountd` NFSv4 is mentioned : > -N mountd-version or --no-nfs-version mountd-version > This option can be used to request that rpc.mountd do not offer certain > versions of NFS. The current version of rpc.mountd can support both NFS > version 2, 3 and **4**. If the either one of these version should not be > offered, rpc.mountd must be invoked with the option --no-nfs-version <vers> Regards
(In reply to Maxime de Roucy from comment #2) > Actually, from my tests rpc.mountd is also needed on pure NFSv4 server. I tried it and you're right. On my machine I get an mount.nfs4: access denied by server while mounting if rpc.mountd is not running. It seems rpcbind is also required to start rpc.nfsd. I think smnotify is not required for v4 but I'm not sure.
Created attachment 424448 [details, diff] Patch to make rpc.statd optional
(In reply to Roland Hopferwieser from comment #3) > I tried it and you're right. On my machine I get an > > mount.nfs4: access denied by server while mounting I get the same error when I try to disable rpc.mountd. > if rpc.mountd is not running. It seems rpcbind is also required to start > rpc.nfsd. I think smnotify is not required for v4 but I'm not sure. I don't think rpcbind is required. I am running an nfsv4 server with : /usr/sbin/rpc.svcgssd (only for kerberos, not needed if you don't use sec=krb5) /usr/sbin/rpc.idmapd -S /usr/sbin/rpc.mountd -N 2 -N 3 On systemd, nfs-server.service : Requires=proc-fs-nfsd.mount nfs-mountd.service basic.target network.target Wants=nfs-idmapd.service rpc-svcgssd.service system.slice client : /usr/sbin/rpc.gssd (only for kerberos, not needed if you don't use sec=krb5) on systemd, nfs-client.target : Wants=remote-fs-pre.target rpc-statd-notify.service auth-rpcgss-module.service WantedBy=remote-fs.target multi-user.target
This is still an issue. I recently disabled NFS v3 in the kernel of my NFS server and disabled the nfsv3 useflag for nfs-utils, then /etc/init.d/nfs would fail to start because it was relying on rpc.statd, which would fail to start. The attached 8+ year old patch still worked (I applied the changes manually), but then /etc/init.d/nfs was failing to start with different errors in syslog: rpc.mountd[8290]: mountd: No V2 or V3 listeners created! rpc.mountd[8292]: Version 2.6.4 starting kernel: svc: failed to register nfsdv3 RPC service (errno 111). /etc/init.d/nfs[8232]: ERROR: nfs failed to start So after looking at the manpages for rpc.nfsd and rpc.mountd, I tweaked their command-line options via the /etc/conf.d/nfs file, adding "-N 3" to OPTS_RPC_NFSD, and adding "-N 2 -N 3" to OPTS_RPC_MOUNTD (nfsd failed to start when I tried it with "-N 2" because it doesn't recognize protocol version 2 anymore, but mountd still supports protocol version 2 so it should probably be explicitly disabled). (While I was at it, I also added -s (log to syslog) to OPTS_RPC_NFSD.) With those fixes, plus the attached patch, /etc/init.d/nfs started working again. BTW, as an alternative to disabling the protocols via command-line, you could create /etc/nfs.conf containing the following: [nfsd] vers3 = off This property is read and used by both rpc.nfsd and rpc.mountd, however I think the command-line options provide more nuanced control and so should be preferred (not to mention you already have an /etc/conf.d/nfs file).
BTW I saw information that rpc.mountd is not needed for NFSv4, but I could not get the clients (which is explicitly using NFSv4 only) to mount if the server hadn't started mountd.
The attached patch disables /etc/init.d/nfs's hard dependency on rpc.statd (which fails to start when NFSv4-only) and also disables the starting of sm-notify (which is not necessary when NFSv4-only). As an alternative to editing an init script, you can somewhat hackily achieve a similar effect by editing /etc/conf.d/nfs and setting OPT_RPC_STATD="-v". This option to statd makes it just print the version and exit (with a non-zero status). OpenRC will think the "rpc.statd" service has crashed, but that does not seem to impede NFS. I'm not suggesting this to be the official solution, but readers of this may decide this to be a more palatable workaround until a proper fix is implemented.