Permanently mapping a network drive on MacBook Pro

findermountnasNetworksleep-wake

THE QUESTIONS:

  1. How can I make my MacBook Pro automatically mount a network share when it wakes up?
  2. How can I make sure that when it is mounted it is mapped to the same path (/Volumes…)

MY SETUP:

I have a MacBook Pro running the latest OS X, and I also have a NAS in the house. From Finder I connected the NAS to my MacBook, and it shows up in the shared drives on the Finder bar together with all the other links (like Desktop, All my files…etc.). I also have a password saved in my keychain, so I do not have to type it in.

THE PROBLEM IN DETAIL:

This network share is not mounted automatically, i.e. I have to click on the link in Finder to get it mounted (on /Volumes/…), otherwise other programs do not see it. When my MacBook sleeps it will be automatically dismounted though but not mounted again when I wake the computer up. Even worse, after manual mounting with a click in Finder, the path at /Volumes will be a different one, so some programs lose the path.

WHY IT IS ANNOYING:

A prime example is Adobe Lightroom (LR): I keep lots of photos on the NAS share, and LR add these photos to its database found on the MacBook's local drive. But it does not copy the files over from the network share just links to each of them and generates a (much smaller size) thumbnails. Now when the MacBook wakes up, and I go to LR, the drive does not exist, it is not mounted. I have to go to finder, click and mount it, then back to LR where now I can see it. But sometimes the mounting associates the share with a new path, so the old share show lost links in the database, and I have to re-add the photos to LR, under the new path, just to lose it again next time when the Mac sleeps.

This must be an issue for others too, anybody figured it out?

Best Answer

The answer somewhat depends on how the drive is being mounted in the first place.

For example, my AirPort Extreme has a USB drive attached. The Drive Name is 'CrashPlanExtreme' and the AirPort Extreme is (un-creatively) called "Airport-Extreme.local." so I can mount the drive using this command:

open afp://Airport-Extreme.local./CrashPlanExtreme

However, I think I had better success with this:

open -g -a Finder "afp://Airport-Extreme.local./CrashPlanExtreme"

It would be helpful if you mount the drive manually, then go to Terminal.app and enter this command:

mount | egrep '^/'

then add the output to your question.

Once we determine the correct Terminal command to mount the drive, the rest is simply a matter of writing a script that runs when you log in (easily accomplished using launchd) and when the computer wakes from sleep (easily accomplished using the free and excellent sleepwatcher.)