How to mount NFS share as a regular user

In order to allow a regular user to mount NFS share, you can do the following.

On the NFS client host (e.g., 10.1.1.20), update /etc/fstab as root.

$ sudo vi /etc/fstab
10.1.1.10:/export/alice /home/alice/Desktop/mnt nfs rw,noauto,user 0 0

In the above, "user" allows a non-root user to mount, and "noauto" means no automatic mount on boot.

On the NFS server host (e.g., 10.1.1.10), enable export for the client as root.

If you want to enable export non-permanently (which is not persistent across reboots):

$ sudo exportfs 10.1.1.20:/export -o rw,async,no_root_squash,no_subtree_check

If you want to enable export permanently (which is persistent across reboots):

$ sudo vi /etc/exports
/export 10.1.1.20(rw,async,no_root_squash,no_subtree_check)
$ sudo exportfs -a

Now you can log in as "alice" on the NFS client host, and do NFS mount as follows.

$ mount /home/alice/Desktop/mnt

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

Leave a comment

Your email address will not be published. Required fields are marked *

Current ye@r *