Last updated on October 15, 2020 by Dan Nanni
If you are a non-root regular user and attemp to mount a remote NFS share, you will get the following error:
mount: only root can do that
In order to allow a regular user without root privilege to mount a remote home directory via NFS, you can do the following.
On the NFS client host (e.g., 10.1.1.20
), update /etc/fstab
as root. I assume that the user requiring NFS mount is alice
.
$ sudo vi /etc/fstab
10.1.1.10:/export/alice /home/alice/Desktop/mnt nfs rw,noauto,user 0 0
In the above configuration, the user
option 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 temporarily one time (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), edit /etc/exports
as follows.
$ sudo vi /etc/exports
/export 10.1.1.20(rw,async,no_root_squash,no_subtree_check)
Finally, run this command:
$ 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
This website is made possible by minimal ads and your gracious donation via PayPal or credit card
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.
Xmodulo © 2021 ‒ About ‒ Write for Us ‒ Feed ‒ Powered by DigitalOcean