So naturally I think, "There's got to be a better way. Microsoft figured out long ago in Windows how to automatically reconnect network shares if the NAS is disconnected from the server or workstation, why not Apple?" Well, it turns out Apple has this figured out as well. They just don't provide the user-friendly checkbox to enable the capability.
I found a couple of very useful resources on my latest search for an answer (thanks Google). The first was this white paper that Apple released in 2009 that details how to use autofs. For those that want to understand the full capability, it's the place to start. For those that want the Cliff's Notes version, there's a great post on Superuser.com that explains how to get the solution up and running quickly. I've read both, and I chose the indirect mapping method described in the post for setting up my auto-mounted share. And so far, so good. I purposely held off on a software upgrade on the NAS until after I made the auto-mount change to see how resilient the solution is, and it works great. Be sure to tune down the AUTOMOUNT_TIMEOUT value in /etc/autofs.conf. The default value is 3600 seconds. I've tuned it down to 300 (5 minutes), and all seems well.
One side note: when you change from traditional mounting of the share via Finder to mounting via autofs, the mount point for the share changes as well. While Finder will automatically mount the share under the /Volumes directory, autofs pretty much lets you mount anywhere. Best practice (Greg practice?) is to mount the NAS shares under the /Network directory. I mount mine as /Network/NAS_Name/share_name
One last note: you will lose the little drive icons that Finder puts on your desktop when you mount network shares with it. Not a big deal, but if it bothers you, you can always just create aliases on the desktop instead.
Well, happy auto-mounting!
Update: November 25, 2015
So while all seemed well when I originally wrote this blog, I've noticed on several occasions where iTunes opens before the NAS volume is mounted. When this happens, iTunes silently reverts the location of my iTunes library to my local SSD. So now rather than launch iTunes directly, I wrote this handy Automator script that will test for the existence of a file on the volume, and only launch iTunes if the file exists. The beauty is that testing for the file will automatically mount the volume if it can be mounted:
if [ -f /Network/NAS/media/00-media-is-alive ]; then
open /Applications/iTunes.app
else
osascript -e 'display notification "Folder media is missing. Failed to start iTunes." with title "Automator"'
fi
Then just run the command "touch /Network/NAS/media/00-media-is-alive" from a terminal window and you're good to go. Instead of launching iTunes directly, run the script instead. If the script can verify that the file 00-media-is-alive exists, meaning that the volume is mounted, it will start up iTunes. If not, then you will get a message in Notification Center telling you that iTunes failed to start because the volume with the iTunes library couldn't be mounted.
No comments:
Post a Comment