How to Mount NFS Share from macOS to Ubuntu 20.04 Server: Complete Guide with Code Examples


1 views

Before starting, ensure you have:

  • Ubuntu 20.04 server with NFS server installed
  • macOS Catalina (10.15) or later client
  • Both machines on the same network
  • Admin/sudo privileges on both systems

First, install NFS server package on Ubuntu:

sudo apt update sudo apt install nfs-kernel-server

Create a directory to share and set permissions:

sudo mkdir -p /mnt/sharedfolder sudo chown nobody:nogroup /mnt/sharedfolder sudo chmod 777 /mnt/sharedfolder

Edit the exports file:

sudo nano /etc/exports

Add this line (replace client_ip with your macOS IP):

/mnt/sharedfolder client_ip(rw,sync,no_subtree_check,no_root_squash)

Apply the changes:

sudo exportfs -a sudo systemctl restart nfs-kernel-server

First, enable NFS client services if not already active:

sudo nfsd enable

Create a local mount point:

mkdir ~/mnt/ubuntushare

Mount the NFS share (replace server_ip with your Ubuntu server IP):

sudo mount -t nfs -o resvport server_ip:/mnt/sharedfolder ~/mnt/ubuntushare

Check mounted shares on macOS:

mount | grep nfs

Test file operations:

touch ~/mnt/ubuntushare/testfile ls -la /mnt/sharedfolder/ # On Ubuntu server

For persistent mounting after reboot, edit /etc/fstab on macOS:

sudo nano /etc/fstab

Add this line (use your actual server IP and paths):

server_ip:/mnt/sharedfolder /Users/youruser/mnt/ubuntushare nfs rw,resvport 0 0

Common issues and solutions:

# If mount fails, check server exports: showmount -e server_ip # Check NFS service status on Ubuntu: sudo systemctl status nfs-kernel-server # Check firewall rules: sudo ufw status sudo ufw allow from client_ip to any port nfs

For better performance with large files:

sudo mount -t nfs -o resvport,rsize=65536,wsize=65536,hard,intr server_ip:/mnt/sharedfolder ~/mnt/ubuntushare

For mixed macOS/Linux environments:

sudo mount -t nfs -o resvport,nolockd,noac,actimeo=3 server_ip:/mnt/sharedfolder ~/mnt/ubuntushare

Before proceeding, ensure:

  • Ubuntu 20.04 server with NFS server package installed
  • macOS Catalina (10.15) or later client
  • Both machines on same network (or properly configured for remote access)
  • sudo/root access on both systems

First, install required packages on Ubuntu:

sudo apt update
sudo apt install nfs-kernel-server

Create or choose a directory to share (example using /mnt/share):

sudo mkdir -p /mnt/share
sudo chown nobody:nogroup /mnt/share
sudo chmod 777 /mnt/share

Edit the exports file:

sudo nano /etc/exports

Add this line (adjust IP range for your network):

/mnt/share 192.168.1.0/24(rw,sync,no_subtree_check,no_root_squash)

Apply the changes:

sudo exportfs -a
sudo systemctl restart nfs-kernel-server
sudo ufw allow from 192.168.1.0/24 to any port nfs
sudo ufw enable

First, ensure NFS client is enabled (should be by default). Create mount point:

mkdir -p ~/mnt/ubuntu_share

Mount the share (replace IP with your server's IP):

sudo mount -t nfs -o resvport,rw 192.168.1.100:/mnt/share ~/mnt/ubuntu_share

Check mounted filesystems:

mount | grep nfs

Create test file:

touch ~/mnt/ubuntu_share/testfile.txt

Edit /etc/auto_master:

sudo nano /etc/auto_master

Add this line:

/net    -hosts    -nobrowse,hidefromfinder,nosuid

Create auto_nfs file:

sudo nano /etc/auto_nfs

Add mount entry:

~/mnt/ubuntu_share -fstype=nfs,rw,resvport 192.168.1.100:/mnt/share
  • Check connectivity: ping server_ip
  • Verify exports: showmount -e server_ip
  • Check server logs: sudo tail -f /var/log/syslog
  • Try mounting with verbose: sudo mount -v -t nfs ...