# [help] Remount NFS when remote export remounted

## koan

Hello,

I have an NFS export defined on one server, that is a mount point for a USB storage device that is not always present.  The usb device is mounted with autofs when the device is present.

The NFS export is mounted on another server, which ultimately exposes it with samba to the network.  If the nfs share is mounted while the usb device is absent, then the nfs share is naturally empty.  If the usb device is subsequently mounted, this is not seen by the remote server - it still has the empty mount point in its share.  It needs to unmount and remount the nfs share to see the usb device contents.

I am wondering if there is a way to trigger this automatically - to let the remote server know that the situation has changed, or to have the remote server detect that there is something new at the share.

Cheers,

Paul

----------

## nativemad

absolutely no guarantee... i'm not sure if this is the only way as it's definitively a bit hacky and i don't know if it will work at all!    :Rolling Eyes: 

Use incron to monitor the mountpoint and trigger a command (or use another automounter that can run external commands directly, but honestly i don't know if such a thing exist at all!?).

The external command would then be something like `ssh remotehost mount -o remount /nfs/path` with previously authorized ssh-keys. 

I hope you will get the idea...

Cheers

----------

## koan

Aah, incron...  inotify would trigger on a mount?  I guess I could do something similar with udev as well.

Good thinking.

I noticed that a remount wasn't enough to get the new directory, I had to unmount and mount again.

----------

## nativemad

 *koan wrote:*   

> Aah, incron...  inotify would trigger on a mount?  I guess I could do something similar with udev as well.
> 
> 

 

I just tried it, but actually incron doesn't react on at least bind mounts...   :Rolling Eyes: 

But what works is monitoring /etc/mtab! -Just start a script via incron that greps for the usb-mountpoint in /etc/mtab. If there is an entry, ssh over and mount, otherwise umount.   :Razz: 

----------

