NFS v4 and UID

Hi,

I used “dietpi-drive-manager” to setup a nfs v4 share under the “/mnt/nfs_client”. I can mount it too on my macbook laptop using the following command

sudo mount -o resvport,vers=4 -t nfs dietpi.local:/ /Users/cmoullia/private/nfs

but the files displayed under the shared drive corresponds to UID which are unknown on my machine

ls -la /Users/cmoullia/private/nfs
total 56
drwxrwxr-x  8 1000      1000   4096 Dec  8 18:52 .
drwxr-xr-x  5 cmoullia  staff   160 Nov 13 12:33 ..
drwxrwxr-x  2 1000      1000   4096 Dec  8 14:40 Music
drwxrwxr-x  2 1000      1000   4096 Dec  8 14:40 Pictures
drwxrwxr-x  2 1000      1000   4096 Dec  8 14:40 Video
drwxrwxr-x  2 1000      1000   4096 Dec  8 17:35 downloads
drwxr-xr-x  6 110       117    4096 Dec  8 18:57 grafana
drwxr-xr-x  6 998       998    4096 Dec  8 15:53 node-red

I can only copy files using sudo/root on mac. Is there a way to avoid to use “sudo” to copy files ?

Cheers

Charles

Please check out the explanation in the mount man page: https://manpages.debian.org/bullseye/mount/mount.8.en.html#Non-superuser_mounts

Hence in /etc/fstab, add the ,user to the mount options, then I probably sudo systemctl daemon-reload is required to reload it. Then try again as unprivileged user.

… ah wait, I think I misunderstood, you want to mount it as unprivileged user on macOS. Generally since it is UNIX as well, the same may work on macOS as well, but not sure. But this is not something that can be controlled server-wise, instead it needs to be configured on the client system (macOS).

… ah and misunderstood another thing :rofl:, not mounting the drive as unprivileged user is the issue, but writing files in the mount point. Try to change the mode either on the server or on macOS (as root): sudo chmod -R 0777 /Users/cmoullia/private/nfs

You can also change the owner:group, sudo chown -R root:root /Users/cmoullia/private/nfs
With 0777 mode the owner doesn’t matter, but root is assured to be UID 0 and GID on both systems, with every other user it is possible that it doesn’t exist on one end. As alternative you can create the macOS user at the server with the same UID, like: useradd -u 1234 cmoullia

Many thanks. I will check/review what you reported.

Instead of using NFS, I should perhaps use samba as we dont have by default this problem

  1. Macbook

On the mac machine where a samba shaed drive is mounted, files appear using my user cmoullia and group staff

ls -la /Volumes/pi-music/
total 200
drwx------  1 cmoullia  staff  16384 Dec  9 07:16 .
drwxr-xr-x  4 root      wheel    128 Dec  9 07:11 ..
-rwx------@ 1 cmoullia  staff  12292 Dec  9 07:21 .DS_Store
-rwx------  1 cmoullia  staff   4096 Dec  9 07:16 ._.DS_Store
drwx------  1 cmoullia  staff  16384 Oct 21 12:26 Marillion
drwx------  1 cmoullia  staff  16384 Oct 21 09:46 Metallica
drwx------  1 cmoullia  staff  16384 Oct 22 09:00 Queensrÿche
  1. RockPro64

On the RockPro64 DietPi box, files are owned by dietpi and group dietpi

root@DietPi:/media/dabou/Music# ls -la
total 24
drwxr-xr-x 6 dietpi dietpi 4096 Dec  9 07:16 .
drwxr-xr-x 9 dietpi dietpi 4096 Dec  8 19:02 ..
drwxrwxr-x 6 dietpi dietpi 4096 Oct 21 12:26 Marillion
drwxrwxr-x 5 dietpi dietpi 4096 Oct 21 09:46 Metallica
drwxrwxr-x 4 dietpi dietpi 4096 Oct 22 09:00 Queensrÿche

Samba cfg

[pi-music]
	comment = Pi Music Share
	path = /media/dabou/Music
	browseable = yes
	create mask = 0664
	directory mask = 0775
	valid users = dietpi
	writeable = yes

yes files show up as user dietpi on Samba server side becuase this is the user you use to login to Samba server.

valid users = dietpi

Jep, generally other than NFS, Samba does not sync any metadata, so permissions, owner etc depends on the server config server-side, and client config client-side only.