Given user (user1:u=1000,g=1000) on a ubuntu 20.04 machine,
and an nfs share defined on a WD ex2 ultra under OS5
I want that a file created by user1 on ubuntu on that share be owned by user1.
For now the file is owned by 501.
Detailed steps:
defintion of share on NAS
-
cat /etc/exports
“/nfs/test” *(rw,all_squash,sync,no_wdelay,insecure_locks,insecure,no_subtree_check,anonuid=501,anongid=1000) -
cat /etc/passwd
nobody:x:501:1000:Linux User,:/home/nobody:/bin/sh
user1:x:1000:1000:user1,:/usr/share/ftp:/bin/sh -
ls -l /nfs
lrwxrwxrwx 1 root root 7 Apr 23 09:29 /nfs → /shares -
ls -l /shares
lrwxrwxrwx 1 root root 18 Apr 23 08:04 test → /mnt/HD/HD_a2/test
creation of file on ubuntu:
use user1 login
-
id user1
uid=1000(user1) gid=1000(user1) groupes=1000(user1),4(adm),27(sudo)
note: user1 is defined with same uid, gid on NAS and ubuntu machine. -
cat /etc/fstab
192.168.1.72:/nfs/test /media/test nfs rw, 0 0 -
sudo mount -a
-
ls -l /media
drwxr-xr-x 2 root root 4096 févr. 18 22:47 test -
create file
touch /media/test/testfile.txt -
verify ownership
ls -l /media/test/testfile.txt
-rw-rw-r-- 1 501 user1 0 avril 29 2021 testfile.txt
drwxr-xr-x 12 root root 4096 avril 22 19:22 …/
My objective is to have user1 as file owner, not 501,
and similarly have files created by other users on the nfs share owned by their respective creator.
Is it possible to obtain such behaviour with nfs? And how?