Different directory structures depending on whether network is active or not using autofs

Latest response

Sorry if this has been asked and answered already -- a quick scan of posts did not come up with the answer.

It is known that a directory, say /foo can have one directory structure when there is no NFS mount at that mountpoint and have a second directory structure when a NFS filesystem is mounted at that point.

When a filesystem is NFS mounted at /foo, the directory structure that was there is "hidden" and whatever is served from the NFS server is now visible.

I would like this same behavior to exist under autofs -- when the network is unavailable, a first directory structure, and when the network is available and autofs can mount a filesystem from a server, the NFS filesystem is visible.

The problem is that the indirect mountpoint (/mnt in my setup) is owned by the map file (/etc/auto.direct in my setup) and even as root, I cannot create or alter anything under /mnt.

The hope was that I could create something like /mnt/foo and within /mnt/foo I could create a file called /mnt/foo/bar when there was no network.

If my auto.master file has:

/mnt /etc/auto.direct

and my /etc/auto.direct file has:

foo server:nfsfilesystem

I was hoping that without network connectivity, ls /mnt/foo would return the file "bar" while when the autofs was functioning /mnt/foo would return the nfsfilesystem from server.

Alas, I can't seem to get this to work. Is this even possible?

Ken

Responses