The Power of the Network File System (NFS)
When connecting to shared folders on a local network, most macOS users rely on SMB (Server Message Block), the protocol developed by Microsoft. While SMB is excellent for Windows compatibility and general file sharing via Finder, it is not always the fastest or most efficient protocol for Unix-based environments.
If you are connecting a Mac to a Linux server, a high-performance NAS (Network Attached Storage), or an enterprise storage array, you should consider using NFS (Network File System). NFS is a native Unix protocol that often provides significantly lower latency and higher throughput than SMB, making it ideal for video editing, large database transfers, and automated backups.
While macOS supports NFS natively, the Finder interface for mounting it is notoriously unreliable. For a robust, stable connection, especially one you intend to automate or script, mounting the NFS share directly via the Terminal is the best approach.
Prerequisites
Before you begin, you need two pieces of information:
- The IP Address of the NFS server (e.g.,
192.168.1.50). - The Export Path: The exact directory path being shared by the server (e.g.,
/mnt/volume1/shared_data).
Unlike SMB, NFS (in its standard configuration) relies on IP-based security rather than usernames and passwords. Ensure the NFS server is configured to allow connections from your Mac’s specific IP address.
Step 1: Creating the Local Mount Point
In Unix-based systems like macOS, network drives do not appear as separate “C:” or “D:” letters. Instead, they must be attached to an empty folder on your local hard drive. This folder is called the “mount point.”
Open the Terminal application (found in Applications > Utilities) and create a new, empty directory. A common practice is to create this folder on your desktop for easy access.
mkdir ~/Desktop/NFS_Share
You now have an empty folder named “NFS_Share” on your Desktop.
Step 2: Executing the Mount Command
The core command to attach the network drive requires root privileges, so you must use sudo. The command structure tells macOS to use the NFS file system type (-t nfs), specifies the server and path, and finally targets your local mount point.
Type the following command, replacing the IP address and server path with your actual details, and hit Enter:
sudo mount -t nfs -o resvport,locallocks 192.168.1.50:/mnt/volume1/shared_data ~/Desktop/NFS_Share
Understanding the Options Flag (-o)
The -o resvport,locallocks section is critical for macOS compatibility.
- resvport: By default, macOS attempts to connect to NFS servers using a high, unprivileged network port. Many Linux NFS servers reject these connections for security reasons, expecting requests from privileged ports (below 1024). The
resvportflag forces macOS to use a privileged port, preventing instant “Permission Denied” errors. - locallocks: This flag handles file locking locally on the Mac rather than negotiating it over the network. This drastically improves performance and prevents the Mac from hanging if the network connection drops momentarily.
Step 3: Verifying the Connection
If the command is successful, the Terminal will simply return to a new prompt with no output. However, if you look at your Desktop, the generic folder icon for “NFS_Share” will have changed into a network drive icon.
You can also verify the mount point by typing:
df -h
This command lists all connected drives. You should see your NFS server’s IP address listed at the bottom, along with its available storage space and the local mount point.
Step 4: Unmounting the Share
When you are finished using the network drive, you must unmount it properly before disconnecting your Mac from the network, or Finder may crash.
Do not simply drag the folder to the trash. Instead, use the umount command (note the spelling: there is no “n” after the “u”).
sudo umount ~/Desktop/NFS_Share
The network drive icon will revert back to a standard, empty folder, and it is now safe to disconnect.