0

I'm trying to wrap my head around connecting my Pi2B to a NAS using NFS. In this answer, @Ingo wrote.

As customary then you mount to nfs shares with entries in /etc/fstab. This line in your /etc/fstab should do it: 192.168.1.152:/nfs/Music /home/pi/nas nfs _netdev,auto 0 0

But which user requires permissions on the NAS to mount this drive? No one is logged on at this point, are they?

1
  • It's the root user of course.
    – Seamus
    Commented Jan 2, 2021 at 18:24

2 Answers 2

2

To elaborate the answer of @Seamus, you have to differentiate between the mount action and the access to the mount point. in principle these have nothing to do with each other. Following the Unix paradigma "everything is a file", a remote filesystem is mounted to a local directory so you can access its content like local files. So mounting the filesystem is just doing that. By default this can only be done with root rights. With entries in /etc/fstab mounting is done by the operating system at boot up and the operating system uses root rights for this.

It is possible to mount filesystems with user rights, but that needs additional helper programs or entries in /etc/fstab (options user, or users) but that is out of scope here. Have a look at man mount.

As already said, mounting has nothing to do with access rights to the mount point. If you have mounted a filesystem with whatever rights then you will see the access rights that have been setup before on the filesystem or given by the sharing process (nfs with /etc/exports, samba with /etc/samba.conf, etc.). After a mount just look at its rights with, e.g.

rpi ~/$ sudo ls -la /mnt
3
  • But if I run sudo mount //192.168.0.20/video/tv /mnt/nas/tv it responds with: Password for root@//192.168.0.200/video/tv:. I get what you're saying about root rights on the local machine but it appears to want root access to the NAS, as well. Commented Jan 3, 2021 at 20:14
  • @serialhobbyist This seems to be a configuration issue on the nfs server. On a linux box you would look at /etc/exports with doku in man exports and focus on root_squash, but also other options.
    – Ingo
    Commented Jan 3, 2021 at 20:26
  • 1
    @serialhobbyist: Your question seems to have morphed into How Do I Setup My NFS Server? That's moving into off-topic territory... I'd tell you if I knew, but you can find these answers for the price of an Internet search, or you may find what you need here
    – Seamus
    Commented Jan 3, 2021 at 23:41
2

The root user mounts the drive. After it is mounted, the permissions on the NFS server will apply on a per-user basis.


With respect to the related question, How Do I Setup User Permissions On My NFS Server?

You can find these answers for the price of an Internet search, or this may provide what you need.

2
  • Does the same thing apply when a user is logged on: it's still mounted by root? In other words, if I get something working whilst logged on, and then put the same command in fstab, it should still work? Commented Jan 3, 2021 at 9:26
  • @serialhobbyist: Don't confuse yourself. All I was trying to say was that root privileges are required to mount a device. Once it is mounted, the individual user's privileges will determine if that user may read, write or execute files and directories on the mount-ed volume.
    – Seamus
    Commented Jan 3, 2021 at 23:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.