1

I have a NAS that I run out of my home. I always keep a directory on the NAS (~/mydata) mounted on my laptop (at ~/nas). When I am at home, I mount the volume over the LAN. When I am not at home, I mount it over the Internet. I would like to automate the mounting process to:

  • (a) Mount when I connect to a network
  • (b) Unmount when I disconnect from a network
  • (c) Mount when I log in

I have a launchd specification that runs a script whenever a network change (switch, connection, or disconnection) occurs. But I can't figure out how to detect whether a previously mounted volume is accessible. The problem is that once my volume is mounted, even if I disconnect from the network and the mounted volume is no longer accessible (either because I used a .local hostname that only works on my home network or because there simply is no network connection at all), the OS doesn't seem to know this. I've tried a couple tests:

  • mount: the output of argumentless mount continues to show the mounted volume, with no indication of inaccessibility
  • cd ~/nas: hangs
  • df: hangs
  • umount: hangs

I am on macOS and am using sshfs to do the mounting. How can I check whether a mounted volume is still accessible?

  • If your question is related only to sshfs you should have a look here . IMHO the best way is to let mount, with right timeout/reconnection settings, to take care of it. – sgargel Feb 15 '17 at 9:51
-1

To check whether a mount already exists or not use the following command and check for fuse.sshfs :

mount | grep fuse.sshfs

Also to mount or unmount file system refer this man page.Try unmounting it and mount again.More of this here

  • 1
    Thanks for your response sai. A few problems though: (1) as I explain in the question, the output of mount continues to show the mounted volume after it has been disconnected. (2) the mount output indicating the mount doesn't even show fuse.sshfs; instead it shows USER@HOST:/host/path on /target/path (osxfuse, nodev, nosuid, synchronous, mounted by smackesey) – Sean Mackesey Feb 15 '17 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.