How chown command work in case of NFSv4 ?

NFSv4 handles user identities differently than NFSv3.  In NFSv3, an nfs client would simply pass a UID number in chown (and other requests) and the nfs server would accept that (even if the nfs server did not know of an account with that UID number).  However, v4 was designed to pass identities in the form of @.

Now if chown command is failing while issuing from NFS client two possible reasons could be.

–> Domain name issue on NFS server and client.

–> Same user is not present on both NFS server and client.

I have created some scenarios in my test lab. I have used RHEL as NFS server and another RHEL vm as NFS client. Results of some of tests may vary if you are using different NAS server like EMC and Netapp.

Setup Info : Some basic information about my setup. /vicky is exported from NFS server, its having the ownership of user3:user3. Notably user3 is present on both NFS server and client with same UID.

[root@nfsserver ~]# df -h /vicky
Filesystem                Size  Used Avail Use% Mounted on
/dev/mapper/nfsvg-nfslv1  485M  6.3M  454M   2% /vicky

[root@nfsserver ~]# cat /etc/exports | egrep -v “^#|^$”
/vicky *(rw,sync,no_root_squash)

[root@nfsserver ~]# ls -ld /vicky
drwxrwxrwx. 2 user3 user3 1024 Jun  3 07:02 /vicky

[root@nfsclient ~]# df -h /mnt
Filesystem            Size  Used Avail Use% Mounted on
10.65.210.252:/vicky  485M  6.3M  454M   2% /mnt

[root@nfsclient ~]# ls -ld /mnt
drwxrwxrwx. 2 user3 user3 1024 Jun  3 07:02 /mnt

Test 1 : I deleted the user3 as you done that on your server. Now the ownership is showing in numeric because the user is not present on client. But on server it is still showing ownership as user3:user3.

[root@nfsclient ~]# userdel -r user3

[root@nfsclient ~]# ls -ld /mnt
drwxrwxrwx. 2 502 504 1024 Jun  3 07:02 /mnt

Test 2 : I am changing the ownership to user2:user2 **Notably same user is present on NFS server with same UID and GID.**

On NFS client :
[root@nfsclient ~]# id user2
uid=501(user2) gid=501(user2) groups=501(user2),502(group2)

[root@nfsclient ~]# chown user2:user2 /mnt

[root@nfsclient ~]# ls -ld /mnt
drwxrwxrwx. 2 user2 user2 1024 Jun  3 07:02 /mnt

On NFS server : I am checking the ownership on NFS server its showing like below which is expected because we have change it user2:user2 from client.

[root@nfsserver ~]# id user2
uid=501(user2) gid=501(user2) groups=501(user2),502(group2)

[root@nfsserver ~]# ls -ld /vicky
drwxrwxrwx. 2 user2 user2 1024 Jun  3 07:02 /vicky

Test 3 :  I deleted the user user2 from NFS client and added the same user with different UID. Now user2 is having different UID on NFS server and client.

[root@nfsclient ~]# userdel -r user2

[root@nfsclient ~]# useradd -u 510 user2

[root@nfsclient ~]# chown user2:user2 /mnt

[root@nfsclient ~]# ls -ld /mnt
drwxrwxrwx. 2 nobody nobody 1024 Jun  3 07:02 /mnt

[root@nfsserver ~]# ls -ld /vicky
drwxrwxrwx. 2 510 510 1024 Jun  3 07:02 /vicky

Note : I have noticed in case of EMC NAS server I was not able to issue chown command. If I am mounting the same share with NFSv3 option I was able to perform the chown command.

I will add more test results if I encountered more issues.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s