How to Set Up NFS Mounting Between Ubuntu 20.04 and a Mac Mini
Network File System (NFS) is a powerful and efficient way to share files across a network. If you have an Ubuntu 20.04 machine and a 2014 Mac Mini, you can set up NFS mounting to share files seamlessly. This guide will walk you through the steps to set up an NFS server on Ubuntu and connect it to your Mac Mini.
Step 1: Configure the NFS Server on Ubuntu
1. Install the NFS Server Package
On your Ubuntu machine, install the NFS server software. Open a terminal and run:
sudo apt update
sudo apt install nfs-kernel-server -y
2. Create a Shared Directory
Choose a directory to share with your Mac. For example:
sudo mkdir -p /srv/nfs/shared
sudo chown nobody:nogroup /srv/nfs/shared
sudo chmod 755 /srv/nfs/shared
This ensures the directory has proper permissions for network sharing.
3. Configure the Export File
The /etc/exports file defines which directories are shared and who can access them. Edit the file:
sudo nano /etc/exports
Add the following line to share the directory:
/srv/nfs/shared *(rw,sync,no_subtree_check)
Hereโs what these options mean:
*: Allows any client to access the share. You can replace*with the Macโs IP address for added security.rw: Enables read and write permissions.sync: Ensures data is written to disk before the client is notified.no_subtree_check: Prevents permission issues when accessing subdirectories.
Save and exit the file.
4. Apply Export Settings
Run the following command to apply the changes:
sudo exportfs -ra
5. Start and Enable the NFS Service
Ensure the NFS service is running and will start automatically at boot:
sudo systemctl enable nfs-server
sudo systemctl start nfs-server
6. Allow NFS Through the Firewall
If a firewall is active on your Ubuntu machine, allow NFS traffic:
sudo ufw allow from 192.168.1.0/24 to any port nfs
Replace 192.168.1.0/24 with your networkโs subnet.
Step 2: Mount the NFS Share on the Mac Mini
1. Identify the NFS Server
Find the IP address of your Ubuntu machine. You can use ifconfig or ip a to check. For example, your Ubuntu machine's IP might be 192.168.1.100.
2. Mount the Share
On the Mac Mini, open a terminal and run:
sudo mount -t nfs 192.168.1.100:/srv/nfs/shared /Volumes
Replace /Volumes with the mount point you wish to use on the Mac.
3. Make the Mount Permanent (Optional)
To ensure the share is mounted automatically at startup:
- Open the Macโs
/etc/fstabfile:sudo nano /etc/fstab - Add the following line:
192.168.1.100:/srv/nfs/shared /Volumes nfs rwThis entry will automatically mount the share at boot.
Troubleshooting Common Issues
Permission Denied
If the Mac cannot access the share, verify:
- The directory on Ubuntu has the correct permissions (
chmod 755is a good starting point). - The Macโs IP address is allowed in
/etc/exports.
Firewall Blocking
Double-check that the firewall on Ubuntu is configured to allow NFS traffic.
Mac NFS Client Issues
macOS comes with built-in NFS support. If you encounter issues, ensure the NFS daemon is enabled and running:
sudo nfsd enable
sudo nfsd start
Performance Issues
For better performance, you can tweak the NFS mount options. For example:
sudo mount -t nfs -o rw,async,noatime 192.168.1.100:/srv/nfs/shared /Volumes
Options like async and noatime can help improve speed.