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.

Leave a comment

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

Current day month ye@r *