← ../

Network File System Protocol (v4)

some prerequisites and pitfalls to avoid :

Firewall : the port TCP/2049 should allow inbound connections on the server (in prior versions of NFS, this was more complicated.)

UID/GID : in this setup, everyone can write files, but the standard unix permissions still apply. you may want to make consistent UID/GID either manually, or map them with with idmapd or with setgid etc

Server Configuration :

the nfs-server package (on debian) or the nfs-utils package (centos) needs to be installed

we can then create a directory that we will share with nobody as an owner, nogroup as group, and allow others to create files

mkdir -p /srv/nfs/data
sudo chown nobody:nogroup /srv/nfs/data
sudo chmod o+w /srv/nfs/data

the nfs mounts are defined in the /etc/exports file as such (edit file as root)


entry meaning
/srv/nfs/data the folder we want to export (share) the hosts that are allowed to access it (the clients)
(rw,sync,no_subtree_check) the nfs options for this mount (refer to the man page of exports for the full list of options

for the mounts that we created in /etc/exports to take effect, you need to issue the following command as root

exportfs -a

Client Configuration :

to mount manually :

sudo mkdir /mnt/data
sudo mount -t nfs /mnt/data/

entry meaning
-t nfs the type of the filesystem to mount ip of the server
:/srv/nfs/data the shared directory path on the server
/mnt/data/ local directory on the client

to achieve the same thing in /etc/fstab (edit as root) : /mnt/data nfs defaults 0 0