Nfs – How to mount with uid and gid using NFS

amazon-efsnfsnfs4

I would like to mount an AWS EFS location with the efs driver which internaly uses nfs. Now the question is: How do I automatically mount a location with specific uid and gid? With sshfs e.g. I would just define uid, gid as mount options, but it's not implemented in nfs.

Best Answer

A regular Linux NFS server would do the trick with the following combination of /etc/exportfs options:

all_squash,anonuid=xxx,anongid=yyy

Citing man 5 exports:

  • all_squash - Map all uids and gids to the anonymous user.
  • anonuid and anongid - These options explicitly set the uid and gid of the anonymous account.

With Amazon EFS you'll need locally mounted bindfs layer to change permissions as the server export options cannot be changed.

Please take a look at this Unix & Linux StackExchange question.

It looks like the bindfs currently lacks ability to map all users/groups into one but I guess it could be added to the code quite easily.