I am trying to share portage over nfs using autofs. Recursive nfs mounts are not working, so I am trying to have autofs mount them individually. But, all I get with ls /usr/portage is the distfiles subfolder (i.e. no portage tree from the first mount). Any suggestions?

so how is it supposed to work ? Let us say you first mount /usr/portage . Now /usr/portage perhaps does not contain distfiles subdirectory, because it points to remote system which does not have it (if you had /usr/portage/distfiles on the local system, it will not be visible, because you mount over another file system at /usr/portage). So where does the next instance, /mnt/repo/distfiles is supposed to be mounted on ?

Well, I am just learning too, but direct mounts, as indicated by "/-" in auto.master allows for defining a mount within a filesystem. The standard method is to give autofs a folder (e.g. /mnt/auto) and it creates a folder for each mount.

/usr/portage is part of the root file system on the nfs server. It contains an empty ./distfiles directory where /mnt/repo/distfiles is always mounted. My first hope was that /usr/portage/distfiles would be mounted recursively when /usr/portage is mounted, which I may look into if I cannot find a solution with autofs. My second hope was that when I run emerge, /usr/portage is mounted. Then when the distfiles are needed, that folder is mounted just like it is on the nfs server. But, it shotcuts to mounting /usr/portage/distfiles only. Seems like it should work, but considering direct mounts are just an extension to the system, maybe there are internal design restrictions that prevents it from working.

Something else that is puzzling, there is no /usr/portage/distfiles folder locally, just /usr/portage. So, it sees distfiles from the first mount, but does not show anything else from that mount, like the entire portage tree.