Automatically Remount Volume

Posted on
Sat Sep 28, 2019 9:21 am
DaveL17 offline
User avatar
Posts: 5075
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Automatically Remount Volume

I have a Raspberry Pi which is running as an SMB file server. I use this setup for storing log files and such.

I attach to the SMB server using the Indigo user's startup items and the share mounts successfully when the Indigo user is first logged in. However, during situations where the SMB server goes down and comes back (RPI reboot, etc.), the Indigo machine doesn't automatically reconnect to the share, and anything that's trying to write to the share throws an error. I have to log out of the Indigo user and log back in to reattach (or reconnect to the server in finder). Not a huge burden, but it would be nice to be able to have the volume reattach automatically, wouldn't it?

I tried any number of configurations using launchd, cron, and whatnot--but never got that to work reliably. Then I stumbled on this approach which may be old school, but seems to ALWAYS work. Using Apple's Script Editor, create a new script like this (not mine--I found it online someplace):

Code: Select all
## Save this as an applescript application with the “always open” checkbox checked. (This may be slightly different depending on your version of Mac OS.)
on idle
tell application “Finder”
    set isConnected to disk “share” exists — this checks to see if “share” exists (mounted) then sets a true/false value to the variable “isConnected”.
end tell
if isConnected = false then — this checks variable “isConnected” and if “false” then it tries to mount the volume given the server name (or ip address).
    try
    mount volume “share” on server “rpi”
    end try
end if
return 30 — this repeats the loop every 30 seconds; this value can be increased/decreased.
end idle
  • Set the script to stay alive and save the script as an application.
  • Add your new application to the Indigo User's startup items.
  • Reboot the machine (or at least log out and log back in).
You can test whether the application is working properly by ejecting the volume. Within 30 seconds, the share should remount "automatically".

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest