Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Server A exports directory /srv via NFS with option nohide. A subdirectory within /srv, /srv/foo, is a mount point for another location on the NFS server using --bind option, like

server# mount --bind /bar/foo/ /srv/foo/

Client B imports A:/srv and mounts it on /mnt/srv using NFS. Contents of /mnt/srv are the contents of A:/srv.

The problem is that /mnt/srv/foo is empty, while I'm expecting to see the contents of A:/bar/foo/ there.

How to properly export and import NFS shares that have subdirectories as mount points also?

share|improve this question
    
Maybe easier to just use symlink on A from /srv/foo --> /bar/foo ? –  ckhan Jul 6 '12 at 6:55
    
I tried this. This would try to get to the /bar/foo on client machine B, not on server A. –  mbaitoff Jul 6 '12 at 10:59

3 Answers 3

up vote 2 down vote accepted

Looks like every mount sub-point must be exported by the NFS server in order to be visible for clients. In the situation above the /etc/exports file should look like the following:

/srv        *(rw,fsid=0,nohide,no_subtree_check)
/srv/foo    *(rw,nohide,no_subtree_check)

Then, importing /srv on the client with option -t nfs will make both /srv and /srv/foo properly available.

edit by OP

this line

    /srv/foo    *(rw,fsid=0,nohide,no_subtree_check)

has worked in my case instead of

    /srv/foo    *(rw,nohide,no_subtree_check) 
share|improve this answer

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!

share|improve this answer

I really wanted to do this too, but it seems there are problems with this idea because the NFS clients expect inode numbers of files to be unique within the client's view of a single mount.

The problems are detailed in this blog post (not by me): http://utcc.utoronto.ca/~cks/space/blog/unix/MultiFilesystemNFSIssue

I've decided to mount the filesystems separately and symlink them together, which should work for all NFS clients.

share|improve this answer
    
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  slm May 14 at 22:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.