# Exporting autofs mounted filesystems via nfs

## drescherjm

I have been trying to export autofs mounted filesystems via nfs for some time and I have had nothing but problems with this. Is there any secret to making this work reliably.

Basically my problems is when I go to mount on the client box it either never completes if I try a direct mount or fails if I use autofs to mount. However if the server had the filesystem mounted most of the time it will work.

Is there anyway around this. aufs? 

I guess I could use samba but I would prefer a nfs solution.

----------

## Hu

To be sure I understand this, you have three systems.  The first system is an NFS server exporting some filesystem F.  The second system is an NFS client that has mounted F (possibly via an automounter or possibly manually) and is also exporting the mountpoint where F appears.  The third system is an NFS client attempting to mount the export from the second system, with the intent that reads and writes get relayed back to the first system.  Is this all correct?  If so, may I ask why not just have system #2 and system #3 both mount directly from system #1?

----------

## drescherjm

No the first system is trying to nfs export local ext4 filesystems that are autofs mounted.  A second client is having trouble mounting the nfs exports from the first system.

Basically I want my filesystems to automatically unmount when no local or remote client need to use them.

----------

## tipp98

Did you ever find any success? I am in the same boat. I have a development box that I am trying to bind mount (via autofs) a built, bootable distro into a tftp served directory so that I can pxe boot the distro for testing. 

I could add the bind mount to fstab, but I only work on it about every 6 months, so I don't need it mounted all the time, and more importantly, when I wipe out the output directory and it is recreated via the build system, a deleted folder is still being bind mounted instead of the fresh data. So, its there when I don't need it, but not when I do need it.

When I try to ls the autofs direct mount, all on the 1st system, I get 

```
ls: cannot access /opt/tftpboot/mnt: No such file or directory
```

and ls -l /opt/tftpboot

```
?????????  ? ?    ?       ?            ? mnt
```

There is nothing in dmesg or /var/log/messages about autofs failing to mount.

----------

## drescherjm

At home I worked around this via exporting using samba instead of nfs. At work I believe I am using NFS for a shared distfiles but that has not had any problems in a long long time. I do not have any secret to share. Sorry..

Edit: distfiles is on btrfs now in which the root is always mounted but the subvolume that has the distfiles should not be mounted.

----------

