1

I have an /etc/exports file like this:

/home          remotehost.com(rw,root_squash,anonuid=500,anongid=500)
/home/fred     remotehost.com(rw,root_squash,anonuid=1000,anongid=1000)

Do the two exports work independently of one another or can conflicts occur? For instance, if I mount /home and /home/fred, what will happen? If I unmount /home, will /home/fred stay mounted?

Thanks

1
  • Could you explain what you are trying to accomplish?
    – sciurus
    Apr 30, 2011 at 0:52

2 Answers 2

3

The first line doesn't grant the right to mount /home/fred, it only specifies the one mount point. The second line is independent of the first. Where you mount them to will determine inheritance issues.

3
  • 1
    The first line does grant the right to mount /home/fred if /home and /home/fred are part of the same file system. Apr 30, 2011 at 13:07
  • @Jeff, no, by default the first line will not let you mount /home/fred. You can mount /home, and access 'fred' by that. But that's different from what I said.
    – Chris S
    Apr 30, 2011 at 15:09
  • 2
    Jeff is right. Even if only /home was exported, you could mount just /home/fred if you wanted to. I just verified this on two RHEL 5.6 systems.
    – sciurus
    Apr 30, 2011 at 17:43
2

Let's call your nfs server nfshost.com. Let's say that on it there are two directories in /home

  • /home/fred, owned by the user and group numbered 500
  • /home/bob, owned by the user and group numbered 1000

Let's say that on remotehost.com, you have three empty directories

  • /allhome
  • /justbob
  • /justfred

If you mounted nfshost.com:/home on /allhome, you would be able to see all the contents of nfshost.com:/home on /allhome, i.e. /allhome/bob and /allhome/fred. Since you enabled root_squash and set anonuid and anongid to 500, if the root user attempted to access anything under /allhome, they would do so with the access rights that the user with id 500 or a user in group 500 on nfshost.com has. For example, if /allhome/bob/.profile had the permissions -rw-r-----, root would be able to read and write to it. If /allhome/fred/.profile had the permissions -rw-r-----, root would not be able to access it.

Even though you did not explicitly export /home/bob, since it a subdirectory of a directory that you did export you could mount nfshost.com:/home/bob on /justbob. This would use the same export options you specified for /home.

Even though /home/fred is a subdirectory of another directory you exported, since you explicitly exported it when you mount it the export options you specified for it will take affect. This means that if you mounted nfshost.com:/home/fred on /justfred, anonuid and anongid would be set to 1000. The root user would be able to read and write /justfred/.profile. This would not effect their inability to access the same file through the path /allhome/fred/.profile.

What if you mounted nfshost.com:/home/fred on /allhome/fred? That would mask the contents of /allhome/fred from the nfshost.com:/home export and show the contents from the nfshost.com/home/fred export. In this case, the difference wouldn't be readily apparent, since the files being accessed are the same. However, the export options are not the same. root would now access /allhome/fred with uid and gid of 1000. Now they would be able to read and write /home/fred/.profile.

If you tried to unmount /allhome at this point, you would get an error that the device is busy. You would have to unmount /allhome/fred first.

1
  • Perhaps it has to do with NFS4 vs earlier versions, but in all the testing I've done, the /home/fred export line is completely and utterly ignored, as long as, on the server, /home/fred is on the same filesystem as /home
    – Cheetah
    Jan 22, 2013 at 23:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .