Mount nfs share without root permission

Dear Community,
I am connecting my machine to an NFS server on the network for file sharing and backups and so on.

The command I run is:

sudo mount -v -t nfs 10.1.2.10:/mnt/pool0/incbackup /home/james/pool0/incbackup

To unmount I need to use sudo unmount ...

What would I have to change for mounting and unmounting without sudo permissions? Add my user james into one of the many groups? Which one?

2 Likes

Add an entry to /etc/fstab file:

10.1.2.10:/mnt/pool0/incbackup /home/james/pool0/incbackup nfs noauto,user 0 0

noauto means it won’t be automatically mounted. You can add other options after it if you want. After that, when you want to mount it, run mount /home/james/pool0/incbackup.

3 Likes
sudo dnf install gvfs-nfs
nautilus nfs://host/path

Ctrl+D

5 Likes

Added nfs

Thank you @ersen and @vgaetera for your help. Both solutions work. I am trying to figure out which solution is the “better” one for my use case. Would you mind elaborating on the differences? can gvfs-nfs be considered stable? In the past, I have frequently had nautilus crash or freeze when dealing with network shares.

2 Likes

This depends on your use case specifics and personal preference, but fstab works in kernel space and should be faster than gvfs that works in user space.

2 Likes

Thanks for pointing out the difference, I prefer kernel space tools in this case and will stick with the fstab noauto entry.

3 Likes

You should consider doing a systemd mount with a systemd automount for the share. No need to mess with fstab or manual mount/automount commands, the NFS share will automatically mount when you try to access the path. You can also define how much idle time can pass before it unmounts on its own.

Keep in mind that fstab is auto-converted to systemd units and works the same way.

True, but my recommendation for using systemd mounts and automount units wasn’t necessarily related to performance and more with eliminating user intervention for mounting/unmounting the filesystem, and also not having to manually edit the fstab file, which carries more risk.

1 Like