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      ,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
www-other-folder    -fstype=nfs
www-anotherfolder   -fstype=nfs

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.

/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: Tue, 13 Sep 2022 14:32:15