NFS server is exporting the wrong directories

6,007

Solution 1

I see you are using NFSv4 (the fsid=0 in the /proc/fs/nfsd/exports output gives it away). NFS roots are rquired for NFSv4. You may have better luck with this /etc/exports.

/home                    *(ro,fsid=0)
/home/user1/documents/   *(ro,sync)

You might also need to edit the domain in /etc/idmapd.conf for the server and clients.

On a side note, I highly recommend replacing that asterisk with a subnet if you don't want your data accessable to untrusted systems.

Solution 2

I had a problem with:

/my/dir1 *(rw,sync,fsid=0,crossmnt,no_subtree_check)
/my/dir2 *(rw,sync,fsid=0,crossmnt,no_subtree_check)

and both mount appeared for /my/dir1.

I was trying to use the same default options as given in the Ubuntu 16.04 nfs-kernel-server package /etc/exports example file: https://unix.stackexchange.com/questions/198009/what-provides-etc-exports-and-how-do-i-find-that-out

The solution was to remove fsid=0,crossmnt and use just:

/my/dir1 *(rw,sync,no_subtree_check)
/my/dir2 *(rw,sync,no_subtree_check)

This is also mentioned at: https://forums.opensuse.org/showthread.php/481263-NFS-directs-to-the-wrong-shared-folder/page2?s=ae345ec054b854b5cf036cd1816626f4

I don't really know what all of those do, one day I'll learn NFS. Maybe.

Share:
6,007

Related videos on Youtube

GorillaPatch
Author by

GorillaPatch

Mac/Linux/UNIX enthusiast. I like coding for the Mac, iPhone and nowadays looking much in to Python, Django and Twisted. Also playing around with the Raspberry Pi.

Updated on September 18, 2022

Comments

  • GorillaPatch
    GorillaPatch over 1 year

    It is a bit embarrassing to admit, but I have problems getting my NFS server exporting the right directories. I am using an up-to-date CentOS 6.2 on both the client and the server.

    The server is up and running, the firewall was disabled during the tests.

    On the server side I have created this /etc/exports:

    /home/user1/documents/   *(ro,sync)
    

    this directory is the root of a volume of a software raid. mount output as follows:

    /dev/mapper/lvm--raid-lvol0 on /home/user1/documents type ext4 (rw,nosuid,nodev)
    

    the command showmount -e on the server shows the correct output:

    Export list for servername:
    /home/user1/documents (everyone)
    

    I try to mount that share from the client and get the following output:

    mount.nfs: access denied by server while mounting servername:/home/user1/documents
    

    However when I look afterwards on the server at the file /proc/fs/nfsd/exports I see more than one mountpoint, but not the right one

    # Version 1.2
    # Path Client(Flags) # IPs
    /       *(ro,root_squash,sync,no_wdelay,no_subtree_check,v4root,fsid=0,uuid=696f3ea6:3d7641f3:b6315631:bd63c833)
    /home   *(ro,root_squash,sync,no_wdelay,no_subtree_check,v4root,uuid=696f3ea6:3d7641f3:b6315631:bd63c833)
    /home/user1     *(ro,root_squash,sync,no_wdelay,no_subtree_check,v4root,uuid=696f3ea6:3d7641f3:b6315631:bd63c833)
    

    Where do these entries come from and why is there no line starting with /home/user1/documents ? I tried mounting /home/user1 instead of /home/user1/documents from the client and this strangely works.

    The UIDs of the user are the same on the server and the client. Could it be a problem that the directory to be exported is mounted itself?

    Edit

    The file /var/lib/nfs/xtab is empty.

    • Zachw6
      Zachw6 about 12 years
      For completeness (if the problem still exists) what does /var/lib/nfs/[ex]tab contain?
    • GorillaPatch
      GorillaPatch about 12 years
      This file is empty (I updated my question). The problem still exists.
    • Peter
      Peter about 12 years
      Have you tried mounting without the trailing slash? "/home/user1/documents" instead of "/home/user1/documents/". Also I have never used "*" before, so can't validate that; try using the ip address also. Also, try -v when mounting on the client side. And are there any more routers/firewalls involved between the 2 systmes? Is there a NAT in use (a NAT would cause this due to using an unprivileged port, which should show up if you use -v)?
    • Zachw6
      Zachw6 about 12 years
      @GorillaPatch is /var/lib/nfs/etab also empty ?
    • Janne Pikkarainen
      Janne Pikkarainen about 12 years
      @GorillaPatch: Is this /home/user1/documents/ *(ro,sync) the only content at your /etc/exports?
    • GorillaPatch
      GorillaPatch about 12 years
      yes it is. I am at the moment exporting this directory only.
    • GorillaPatch
      GorillaPatch about 12 years
      @peter no there is no NAT they a attached to the very same switch without any routers on the same subnet.
  • GorillaPatch
    GorillaPatch about 12 years
    Thanks for your help. The asterisk is there for debugging purposes only. Where can I find documentation about NFS roots? This is kind of new to me. I have not seen it in NFSv3.