Most likely you are running into discrepancy between UID / GID on the NFS server and NFS client. I will show how this works based on a simple example.
Let's say you are sharing on your NFS client /nfs_share like this. Notice that nfs_share
is writeable by anyone(777).
[root@nfsserver nfs_share]# cat /etc/exports
/nfs_share 192.168.0.52(rw,no_root_squash)
[root@nfsserver nfs_share]# ls -ld /nfs_share
drwxrwxrwx. 2 root root 4096 Nov 30 23:55 /nfs_share
And mounting on your NFS Client like this
mount 192.168.0.51:/nfs_share /mnt
Now you have on nfs server user called dmitry
[root@nfsserver nfs_share]# getent passwd|grep dmitry
dmitry:x:500:500::/home/dmitry:/bin/bash
[root@nfsserver nfs_share]# getent group|grep dmitry
dmitry:x:500:
And on your nfs client you have user helen
[root@nfsclient ~]# getent passwd|grep helen
helen:x:500:500::/home/helen:/bin/bash
[root@nfsclient ~]# getent group|grep helen
helen:x:500:
Notice that despite those are different users - they have same UID and GID.
So what happens if I touch as user helen file on nfs share?
[helen@nfsclient mnt]$ touch helen_client
[helen@nfsclient mnt]$ ls -lrt
[helen@nfsclient mnt]$ ls -lrt
total 0
-rw-rw-r--. 1 nobody nobody 0 Nov 30 23:58 helen_client
On NFS client this new file will show up as owned by nobody nobody
. This is because nfsidmap can't map client_user_name@domain to server_user_name @domain.
And now moment of truce. Let's check what's the file owner on the nfs server.
[root@nfsserver nfs_share]# ls -rlt
total 0
-rw-rw-r--. 1 dmitry dmitry 0 Nov 30 23:58 helen_client
Surprised yet?
Yet there is nothing strange actually. This works as expected.
NFS server can't map user helen, but what it received is UID and GID. So it created file (since folder is world writeable) with UID 500 and GID 500, which is mapped to dmitry:dmitry on NFS server.
Now let's say we have other user who's UID / GID and names match between server and client
[root@nfsserver mnt]# getent passwd|grep angelina
angelina:x:501:501::/home/angelina:/bin/bash
[root@nfsserver mnt]# getent group|grep angelina
angelina:x:501:
[angelina@nfsclient mnt]$ getent passwd|grep angelina
angelina:x:501:501::/home/angelina:/bin/bash
[angelina@nfsclient mnt]$ getent group|grep angelina
angelina:x:501:
And if I touch file on nfs client as user angelina - I will see correct user name / group on both Server and Client
[angelina@nfsclient mnt]$ pwd
/mnt
[angelina@nfsclient mnt]$ touch angelina_1
[angelina@nfsclient mnt]$ ls -l
total 0
-rw-rw-r--. 1 angelina angelina 0 Dec 1 2016 angelina_1
-rw-rw-r--. 1 nobody nobody 0 Dec 1 00:16 helen_1
[root@nfsserver nfs_share]# pwd
/nfs_share
[root@nfsserver nfs_share]# ls -l
total 0
-rw-rw-r--. 1 angelina angelina 0 Dec 1 00:27 angelina_1
-rw-rw-r--. 1 dmitry dmitry 0 Dec 1 00:16 helen_1
Bottom line is for NFSV4 to work correctly you need to have
- Server and client password / group database in sync. Preferably use ldap.
- client and server should agree on the common domain name
nfsidmap -d