New NFS share on a Linux Server

To add a new NFS export share you have to edit the file /etc/exports on the server side!

sudo nano /etc/exports:

# this is a sample
/var/www                192.168.0.0/16(no_root_squash,rw,no_subtree_check,sync)
/var/www.otherfolder    192.168.0.0/16(no_root_squash,rw,no_subtree_check,sync)
/var/www.anotherfolder  192.168.0.0/16(no_root_squash,rw,no_subtree_check,sync)

After that is done you have to export the folders mentioned in the file above:

prompt$ sudo exportfs -a

Now you should have on the client side a file named auto.yourserverwiththeexports with the following content:

www                 -fstype=nfs     192.168.80.20:/var/www
www-other-folder    -fstype=nfs     192.168.80.20:/var/www.otherfolder
www-anotherfolder   -fstype=nfs     192.168.80.20:/var/www.anotherfolder

Notice that the share name (left side name) doesn't have to be equal to the folder name on the server

and a binding file auto.master file:

# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
+auto.master

/mnt/nas/firstserver               /etc/auto.firstserver --timeout=120 --ghost
/mnt/intranet/secondserver         /etc/auto.secondserver --timeout=120 --ghost
/mnt/nas/yourserverwiththeexports  /etc/auto.yourserverwiththeexports --timeout=120 --ghost

The root folders have to exist: /mnt/nas, /mnt/intranet on the client side

Last update: January 3rd at 5:55pm