How can I do NFSv4 UID mapping across systems with UID mismatches?

With no centralized user administration, the "best" way I see is for you to force all servers to use the same GID and UID for each user. Now ... I'm only talking about files and/or directories.

What I would do in this case is:

  • Register each UID and GID currently in use.
  • Edit /etc/passwd and /etc/group and match the groups on all servers. Preferably to new UIDs and GIDs so the next step will be faster
  • Run this (it will take some time):

    find / -group <OLD_GID> -exec chgrp <NEW_GID> '{}' \+
    find / -user  <OLD_UID> -exec chown <NEW_UID> '{}' \+
    

NFSv4 supports id mapping. When enabled, NFS will transmit user names instead of numeric ids. Hosts having different numeric uid for the same user is not a problem, as user names are mapped to uids on the host.

Id mapping is always used with Kerberos security modes (sec=krb5).

Id mapping can also be used in AUTH_UNIX (the default sec=sys) mode. I have explained configuration details in answer to: How to get NFSv4 idmap working with sec=sys.

Tags:

Linux

Nfs

Users