I had stumbled into this problem while following the Diskless Arch guide, and it really slowed me down. I am going to share my findings here, as I am curious if this will work for anyone else.
As per the Diskless guide I have the diskless client's root filesystem (the actual data I need to export) in a loopback image, which has been mounted on /srv/des1
:
/srv/des1.img on /srv/des1 type btrfs (rw,relatime,compress=lzo,discard,space_cache)
I then created a mountpoint /nfs/des1
then run the mount, and confirm that I can see everything:
# mkdir -p /nfs/des1
# mount --bind /srv/des1 /nfs/des1
# ls -l /nfs/des1
bin boot dev usr #[SNIP]
Referring to the Arch NFS guide, I then put the following in /etc/exports
on the server:
/nfs/ *(rw,no_root_squash,no_subtree_check,fsid=root)
/nfs/des1/ *{rw,no_root_squash,no_subtree_check,nohide)
I then ran an exportfs -rav
on the server to apply these changes.
However I then mounted the share on the test client with: mount server:/des1 /mnt/tmp
only to find it's an empty directory, when I expected the diskless-root-filesystem to be there.
At this stage I tried just about everything until something lead me to this option in the exports
man page:
crossmnt
This option is similar to nohide but it makes it possible for clients
to move from the filesystem marked with crossmnt to exported filesystems
mounted on it. Thus when a child filesystem "B" is mounted on a parent "A",
setting crossmnt on "A" has the same effect as setting "nohide" on B.
So having tried everything else I swapped this around so my /etc/exports
looked like this:
/nfs/ *(rw,no_root_squash,no_subtree_check,fsid=root,crossmnt)
/nfs/des1/ *{rw,no_root_squash,no_subtree_check)
Having read the man page entry you would think this would have the same effect as the previous code, but when I ran exportfs -rav
again to register the changes, then tried to remount from the client and it worked!
/srv/foo --> /bar/foo
?/bar/foo
on client machineB
, not on serverA
.