How to restart nfsd service on macOS
The sudo nfsd restart
command doesn't seem to effect anything. So I tried to stop and then start the service.
When I run
$ sudo nfsd stop
or
$ sudo launchctl unload /System/Library/LaunchDaemons/com.apple.nfsd.plist
it returns:
Stopping the nfsd service (use 'disable' to make permanent)
/System/Library/LaunchDaemons/com.apple.nfsd.plist: Operation not permitted while System Integrity Protection is engaged
How to stop the nfsd service without touching the System Integrity Protection as I found a few information on the net that we should not stop it.
I'm currently using macOS 10.12.4
The following worked for me on macOS Big Sur:
sudo nfsd update
Note thatsudo nfsd reset
command does restart nfsd in a normal system, as evidenced by the pid of /sbin/nfsd
changing.
But if update
and restart
don't work, you should probably check the system log (console app) for errors in your configuration. You could try to kill -9
the daemon and restart it manually of launchd doesn't automatically reload it, and check that the PID changes.
The man page documents the following command line options (among many other things not listed here):
man nfsd
nfsd is normally launched by launchd(8); however, the nfsd command may also be used to manipulate the service using the following commands: enable Enables the nfsd service. disable Disables the nfsd service. start Starts the nfsd service. Note: if the service is disabled it will not be restarted on reboot. Use the enable command to make the change permanent. stop Stops the nfsd service. Note: if the service is enabled it will be restarted on reboot. Use the disable command to make the change permanent. restart Restarts the nfsd service (by stopping the service - it will restart automatically if the /etc/exports file exists). update Sends a SIGHUP to the running nfsd daemon to cause it to update its configuration. status Displays whether the nfsd service is enabled and whether the nfsd daemon is currently running. checkexports Checks the exports file and reports any errors (to stderr). Note that this can be useful to verify the validity of an alternate exports file (using the -F option below) prior to putting the changes in place and updating nfsd.