πŸ–§ NFS Setup Guide β€” MiniPC ↔ Main PC

This guide describes how to share directories between two Linux systems (e.g., MiniPC as server and Main PC as client) using NFS.
It also includes troubleshooting notes and alternative sharing methods.


βš™οΈ 1. Install NFS

On the MiniPC (server)

1
2
sudo apt update
sudo apt install -y nfs-kernel-server

On the Main PC (client)

1
2
sudo apt update
sudo apt install -y nfs-common

πŸ“ 2. Create and prepare shared directory on the MiniPC

1
2
3
sudo mkdir -p /srv/nfs/share
sudo chown -R youruser:youruser /srv/nfs/share
sudo chmod -R 775 /srv/nfs/share

(Replace youruser with your actual username β€” both systems should have the same UID, usually 1000.)


πŸ“ 3. Configure /etc/exports on the MiniPC

Edit the file:

1
sudo nano /etc/exports

Add this line:

/srv/nfs/share 192.168.1.0/24(rw,sync,no_subtree_check)

Then apply changes:

1
2
sudo exportfs -ra
sudo systemctl restart nfs-kernel-server

πŸ”Œ 4. Mount the NFS share on the Main PC

1
2
sudo mkdir -p /mnt/minipc-nfs
sudo mount 192.168.1.50:/srv/nfs/share /mnt/minipc-nfs

(Replace 192.168.1.50 with the actual IP of your MiniPC.)

You can now access /mnt/minipc-nfs like a local folder.


πŸ” 5. Optional β€” make the mount persistent

Add this line to /etc/fstab on the Main PC:

192.168.1.50:/srv/nfs/share /mnt/minipc-nfs nfs defaults,user,rw,soft,timeo=5,retrans=2 0 0

Then test:

1
sudo mount -a

πŸ§ͺ 6. Verify and test permissions

On the Main PC:

1
2
3
touch /mnt/minipc-nfs/test.txt
echo "hello" > /mnt/minipc-nfs/hi.txt
ls -l /mnt/minipc-nfs

If you can create and edit files, your NFS setup works correctly.


πŸ› οΈ Troubleshooting

ProblemLikely CauseFix
“Permission denied” when writingOwnership mismatchEnsure both users have the same UID (id -u) and chown -R youruser /srv/nfs/share
Can read but not writeWrong export optionsCheck /etc/exports β†’ (rw,sync,no_subtree_check)
Mounts disappear on rebootNo fstab entryAdd persistent mount in /etc/fstab
Laggy writesUse sync instead of async in exports for safety (slower but safer)
Need root access from clientAdd no_root_squash to export options (trusted LAN only)

πŸ”’ Security Notes

  • Restrict access to your local subnet: 192.168.1.0/24
  • Avoid exposing NFS ports (2049) to the internet.
  • Use SSH tunnels or VPN (e.g., Tailscale, WireGuard) if you must access remotely.
  • For multiple users, ensure UID/GID mapping consistency across machines.

βš™οΈ Alternatives to NFS

MethodUse CaseProsCons
SSHFSAd-hoc secure mountsEncrypted, easy (works over SSH)Slightly slower I/O
Samba (SMB)Mixed OS (Windows/Linux)Compatible with Windows sharesMore config, heavier protocol
SyncthingContinuous syncEncrypted, auto-syncs both waysNot a live mount, needs both online
rsyncOne-way backups/syncsReliable, scriptableManual or cron-based, no real-time changes
WebDAVRemote over HTTPSSimple, firewall-friendlySlower, permission quirks
VSCode Remote SSHEditing remote filesGreat dev experienceNot general file access

🧰 Quick Commands Recap

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Server side
sudo apt install -y nfs-kernel-server
sudo mkdir -p /srv/nfs/share
sudo chown -R user:user /srv/nfs/share
echo "/srv/nfs/share 192.168.1.0/24(rw,sync,no_subtree_check)" | sudo tee -a /etc/exports
sudo exportfs -ra

# Client side
sudo apt install -y nfs-common
sudo mkdir -p /mnt/minipc-nfs
sudo mount 192.168.1.50:/srv/nfs/share /mnt/minipc-nfs

βœ… Result

You can now:

  • Browse, create, and edit files from your main PC directly on your MiniPC.
  • Use the share in scripts, Docker bind mounts, and backup tasks.

Last updated: 2025-11-01