How to mount with uid and gid using NFS?

21,550

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.

Share:
21,550
Aley
Author by

Aley

Updated on September 18, 2022

Comments

  • Aley
    Aley almost 2 years

    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.

  • Aley
    Aley over 5 years
    Thanks, bindfs might be that, eventhough I dont like the idea of having another program taking care of the permissions as a fuse bind. Reasons are performance, and stability. There is no automount option when something goes wrong with the NFS mount.
  • Kane
    Kane over 4 years
    Not work for me to mount AWS EFS with command sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retra‌​ns=2,noresvport <filesystem id>.efs.cn-northwest-1.amazonaws.com.cn:/ /mnt/efs.