nfs4 and all_squash

all_squash does not work when directory/share is on the same filesystem. Example:

/etc/exports:

/media/mount 192.168.0.0/24(rw,async,no_subtree_check,fsid=0)
/media/mount/folder 192.168.0.0/24(all_squash,anonuid=1000,anongid=100,rw,async,no_subtree_check)

We have to mount folder with a bind to get this working. Move folder to new location, here I’m hiding it:

mv /media/mount/folder /media/mount/.folder
mkdir /media/mount/folder

/etc/fstab:

/dev/sdb1 /media/mount ext4 defaults 0 0
/media/mount/.folder /media/mount/folder none bind 0 0

Mount and reload nfs exports:

mount /media/mount/folder
exportfs -r

Reference: http://www.spinics.net/lists/linux-nfs/msg16593.html