I have a slackware machine (hostname: cyberdyne) that has a directory I want to export via NFS so it can be mounted by my macOS machine (hostname: lightfoot).

The directory I want to export is /home/me/shared. I want to mount this directory on my macOS machine at /Users/me/cyberdyne.

This is /etc/exports:

# Export the directory as the root directory of the virtual file tree:
/home/aaron/shared lightfoot(ro,fsid=root)

lightfoot mounts the export with this command:

sudo mount_nfs -o vers=4,resvport cyberdyne:/ ~/cyberdyne

A stroll through the export flags:

  • ro sets read-only permissions. Note that when macOS mounts an NFS share exported by a linux server it will always have read-only privileges regardless of the flags I set in /etc/exports, but in the future I may mount this export with a linux client, in which case I will have to change this flag if I want read-write privileges for that machine. Setting the ro flag now ensures that I will have to make that decision consciously.
  • fsid=root sets the exported directory as the root of the virtual filesystem. The purpose of this flag is better explained when examining the mount_nfs command below.

A romp through the mount_nfs command:

  • vers=4 enforces the use of NFSv4. The fsid=root flag is only available on NFSv4. And, NFSv4 simplifies ipv6 addressing. Using ipv6 with NFSv3 requires special rpc settings that took me down an ai rabbit-hole for several days before I realized I could bypass all of that by using vers=4, with the added benefit of enabling fsid=root.
  • resvport is necessary when a macOS machine mounts a linux export. It has to do with arcane rules governing which ports are available. I learned that the same result can be accomplished by adding insecure to the flags in /etc/exports but that creates a server-wide exception to the default linux behavior, whilst using resvport as a mount option alters the default behavior only for clients who need it.
  • cyberdyne:/ defines the hostname:/directory being mounted. This is where the benefits of fsid=root really shine. Without fsid=root the hostname:/directory would require an absolute path, e.g. cyberdyne:/home/aaron/shared; and that would require that the client-user know the parent directory structure of the export. fsid=root allows the client-user to mount the export without knowing its locaion on the server.
  • ~/cyberdyne is the mountpoint on the client. Using the ~/ makes the command portable. I have another macOS machine that will mount the same shared directory at the same mountpoint location. I can use the same command without change.