Mount only sub-directory in NFS export
Replace no_subtree_check
with subtree_check
. Make sure fsid
doesn't conflict with the parent export.
The subtree_check
option tells the NFS server to take into account the path on the filesystem when checking its exports for any action. This is typically required when exporting directories along a tree sitting on a sole filesystem. Without this the NFS server will serve requests from the first export record matching the filesystem holding the path targeted by client's NFS commands.
Related videos on Youtube
getack
Updated on September 18, 2022Comments
-
getack over 1 year
On my NAS I export one single filesystem:
/mnt/datastore *(rw,sync,no_subtree_check,all_squash,fsid=0)
With
/mnt/datastore/
being the mount point of a FUSE based concatenation of a bunch of disks.A sub-directory in this export,
/mnt/datastore/dev/
is where I store all the source trees for development work I'm busy with. I have a dedicated VM that I do development on and as such I want to mount this export on it. For safety purposes I am just interested in mounting the subdirectorymnt/datastore/dev/
so that when I mess up, I do not erase my entire collection of movies and TV series.What I've tried:
I created a new export on the NAS:
/mnt/datastore/dev *(rw,sync,no_subtree_check,all_squash,fsid=0)
and mounted that on the dev box in fstab with:
IP_OF_NAS:/mnt/datastore/dev /mnt/dev_directory nfs rsize=8912,wsize=8912,timeo=14,intr 0 0
This does not work as expected: It mounts fine, but I see the contents of
/mnt/datastore/
, not/mnt/datastore/dev/
which defeats the purpose of this exercise.-
Xavier Lucas about 9 yearsReplace
no_subtree_check
withsubtree_check
. Make surefsid
doesn't conflict with the parent export. -
getack about 9 yearsYour trick worked. You can post it as a regular answer so that I can mark it as the answer. Can you also please explain why subtree checking is needed? I do not understand the documentation's description of it fully.
-
Xavier Lucas about 9 yearsDone. See below.
-
-
pgoetz about 6 yearsUsing fsid=0 in both places is what the issue was. fsid=0 is reserved for the root of the NFS export hierarchy. It's not clear that subtree_check is necessary or desirable in this context.