2

I'm using Mac OS High Sierra 10.13, and I'm facing some issues sharing a folder through NFS.

The configuration:

Built-in firewall is disabled and there is no third party firewall installed.

  1. I made sure the nfs service is enabled:

    $ sudo nfsd enable
    

    The nfsd service is already enabled.

  2. I made sure the nfs service is running:

    $ sudo nfsd start
    

    The nfsd service is already running.

  3. I checked with nmap to see ports being listened to:

    $ nmap localhost
    
            
    Starting Nmap 7.60 ( https://nmap.org ) at 2017-10-17 21:53 CEST
    Nmap scan report for localhost (127.0.0.1)
    Host is up (0.00034s latency).
    Other addresses for localhost (not scanned): ::1 10.101.97.98
    Not shown: 995 filtered ports
    PORT     STATE SERVICE
    80/tcp   open  http
    111/tcp  open  rpcbind
    1021/tcp open  exp1
    1023/tcp open  netvenuechat
    2049/tcp open  nfs
    
    
    Nmap done: 1 IP address (1 host up) scanned in 4.34 seconds
    
  4. rpcinfo

    $ rpcinfo -p
    
    program vers proto   port
    100000    2   udp    111  rpcbind 
    100000    3   udp    111  rpcbind 
    100000    4   udp    111  rpcbind 
    100000    2   tcp    111  rpcbind 
    100000    3   tcp    111  rpcbind 
    100000    4   tcp    111  rpcbind 
    100024    1   udp    612  status 
    100024    1   tcp   1021  status 
    100021    0   udp    843  nlockmgr 
    100021    1   udp    843  nlockmgr 
    100021    3   udp    843  nlockmgr 
    100021    4   udp    843  nlockmgr 
    100021    0   tcp   1017  nlockmgr 
    100021    1   tcp   1017  nlockmgr 
    100021    3   tcp   1017  nlockmgr 
    100021    4   tcp   1017  nlockmgr 
  5. Test connection to nfs

    $ telnet localhost 2049
    

    Trying ::1... Connected to localhost. Escape character is '^]'.

  6. Create folder to be shared

    $ mkdir -p ~/tmp/shared-test
    $ touch ~/tmp/shared-test/works.txt
    
  7. Add it to /etc/exports

    $ sudo echo "/Users/user/tmp/shared-test -mapall=-2:-2 -ro" >> /etc/exports
    $ sudo chmod 640 /etc/exports
    
  8. Make sure /etc/exports is correct

    $ sudo nfsd checkexports
    

The issue:

$ showmount -e
showmount: Cannot retrieve info from host: localhost: RPC failed:: RPC: Unable to send; errno = Bad file descriptor
$ syslog
Oct 17 21:56:28 Estebans-MacBook-Pro-2 rpc.lockd[215] : can't contact statd, 100024 RPC: Timed out
--- last message repeated 2 times ---
Oct 17 21:58:29 Estebans-MacBook-Pro-2 syslogd[43] : ASL Sender Statistics
Oct 17 21:59:31 Estebans-MacBook-Pro-2 rpc.lockd[215] : can't contact statd, 100024 RPC: Timed out
Oct 17 22:00:19 Estebans-MacBook-Pro-2 login[1328] : USER_PROCESS: 1328 ttys002
Oct 17 22:00:33 Estebans-MacBook-Pro-2 rpc.lockd[215] : can't contact statd, 100024 RPC: Timed out

I can see rpc.lockd[215] : can't contact statd, 100024 RPC: Timed out all over, as a recurrent log.

$ showmount 127.0.0.1
showmount: Cannot retrieve info from host: 127.0.0.1: RPC: Program not registered
6
  • Excellent troubleshooting... have you tried starting the NFS daemon with launchctl instead? In macOS Sierra (haven't installed High Sierra yet) I first created /etc/exports with contents: /private/tmp -ro, then I ran: sudo launchctl start com.apple.nfsd and checked the RPC information with rpcinfo -p until all daemons were up and running: rpcbind, status (which is in fact rpc.statd), nlockmgr, nfs, mountd and rquotad. It needed a couple of seconds. Then I could mount /private/tmp with: sudo mount -t nfs localhost:/private/tmp /mnt/tmp/ without a problem.
    – jaume
    Commented Oct 17, 2017 at 22:15
  • when doing rpcinfo -p I only get rpcbind, rpcbind, nlockmgr. I do not see nfs, neither mountd nor rquotad. What should be expected?
    – emicha
    Commented Oct 18, 2017 at 17:47
  • If you followed the steps in my previous comment I'd expect that you see nfs, mountd and rquotad listed in rpcinfo's output. You probably need to disable nfsd with sudo nfsd disable (to prevent any conflicts with launchctl) and restart your computer, then start nfsd with launchctl. I'd recommend that you comment out any existing entries in /etc/exports, add a simple export like /private/tmp -ro for troubleshooting purposes and test connecting to localhost.
    – jaume
    Commented Oct 20, 2017 at 7:56
  • I did sudo nfsd disable but rpcinfo -p was showing the same until I restarted the computer. Once I restarted, rpcinfo -p shows rpcinfo: can't contact portmapper: rpcinfo: RPC: Unable to send; errno = Broken pipe. Although, after doing sudo launchctl start com.apple.nfsd, rpcinfo -p still showing rpcinfo: can't contact portmapper: rpcinfo: RPC: Unable to send; errno = Broken pipe
    – emicha
    Commented Oct 21, 2017 at 14:49
  • I think the issue that I see when doing showmount -e 127.0.0.1is because mountd is not launched. If I do sudo nfsd -P 1234 start, that should launch mountd in port 1234, but I do not see it, neither in rpcinfo -p nor nmap localhost
    – emicha
    Commented Oct 21, 2017 at 15:26

1 Answer 1

3

Apparently, I had some issues with my /etc/hosts file. The suspicion was alert seeing rpc.lockd[215] : can't contact statd, 100024 RPC: Timed out all over.

I cleaned up the /etc/hosts file:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost

Restarted the service sudo nfsd restart

And finally when doing showmount -e localhost: Exports list on localhost: /Users/kiwi/user/shared-test Everyone

rpcinfo -p

   program vers proto   port
    100000    2   udp    111  rpcbind
    100000    3   udp    111  rpcbind
    100000    4   udp    111  rpcbind
    100000    2   tcp    111  rpcbind
    100000    3   tcp    111  rpcbind
    100000    4   tcp    111  rpcbind
    100024    1   udp    906  status
    100024    1   tcp   1021  status
    100021    0   udp    730  nlockmgr
    100021    1   udp    730  nlockmgr
    100021    3   udp    730  nlockmgr
    100021    4   udp    730  nlockmgr
    100021    0   tcp   1017  nlockmgr
    100021    1   tcp   1017  nlockmgr
    100021    3   tcp   1017  nlockmgr
    100021    4   tcp   1017  nlockmgr
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    100005    1   udp    989  mountd
    100005    3   udp    989  mountd
    100005    1   tcp   1023  mountd
    100005    3   tcp   1023  mountd
    100011    1   udp    636  rquotad
    100011    2   udp    636  rquotad
    100011    1   tcp    999  rquotad
    100011    2   tcp    999  rquotad
2
  • Thanks for sharing the solution, but what do you mean by cleaning up the hosts file? What was the issue? I have the same problem and I'm not able to fix it.
    – loo3y35
    Commented May 30, 2020 at 14:10
  • @loo3y35 It was a long time ago, but my issue was that my /etc/hosts file had tons of rules (work related) that clashed on how localhost was getting resolved, I can not remember how or which rule exactly. By clean up the /etc/hosts file, I mean remove all rules except for the default ones. The code snippet in my answer is an example of a clean /etc/hosts file.
    – emicha
    Commented May 31, 2020 at 20:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .