NFS
Prerequisites
- Update system
- Install nfs-kernel-server
System update
sudo apt update
sudo apt upgrade
Install NFS
sudo apt install nfs-kernel-server
Create shared DIR and set permissions
sudo mkdir /mnt/nfsshare
sudo chown -R pi:pi /mnt/nfsshare
sudo find /mnt/nfsshare/ -type d -exec chmod 755 {} \;
sudo find /mnt/nfsshare/ -type f -exec chmod 644 {} \;
Get user id and group id
id pi
example output uid=1000(pi) gid=1000(pi)
Share the DIR over NFS
sudo nano /etc/exports
Make sure that you replace the “anonuid” with the “uid” value you retrieved
/mnt/nfsshare *(rw,all_squash,insecure,async,no_subtree_check,anonuid=1000,anongid=1000)
Help
This asterisk defines that all connecting IP addresses should be allowed to access this share. You can change this to allow specific IP’s or an IP range by changing the “*” to the IP. rw – This option allows both read and write requests on the NFS volume. all_squash – This option will map all uids and gids to the anonymous user. insecure – This option allows clients with an NFS implementation that doesn’t use a reserved NFS port. async – This option allows the NFS server to break the NFS protocol to improve performance at the cost of data potentially becoming corrupted if the server crashes. no_subtree_check – This disables subtree checking, while it comes at a cost to security it can improve the reliability of the NFS server. You can read more about this on the exports documentation page we linked earlier. anonuid – This is the UID to utilize for a user that is connecting anonymously. anongid – This is the GID to use for a user that is connecting anonymously.