1. Install required packages

sudo apt update
sudo apt install nfs-kernel-server

2. Add shared locations in /etc/exports

Lets start editing the file /etc/exports and add the following line

<location to share> <host which consumes>(<sharing options>)

For example in my case, I want to share /media/nas to any host 0.0.0.0/0 with read write access rw. You can find further information about options at the end of this post.

...
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
/media/nas 0.0.0.0/0(rw,sync,no_subtree_check)

3. Restart the the NFS server

sudo systemctl restart nfs-kernel-server

Setup a debian host to mount this NFS location


I’m a nerd, I need more…

More information about options

  • ro: mount as read only
  • rw: mount as read and write.
  • no_root_squash: give the remote user the permission of root. Don’t do it unless required.
  • subtree_check: Host should verify the location of files and directories.
  • no_subtree_check: Host should not check the location of the files being accessed.
  • sync: Ensures that the host keeps directory in sync
  • async: Ignore sync checks to increase performance

Adding hosts with different permissions

192.168.0.101 with Read/Write access and 192.168.0.102 with Read only access

/media/nas 192.168.0.101/32(rw,sync,no_subtree_check) 192.168.0.102/32(ro,sync,no_subtree_check)