OS X: How to avoid having to re-connect to network share after NAS was turned off?

20

30

I use Mac OS 10.6 to connect to a NAS drive using the afp protocol (Finder -> Go -> Connect To Server). I have set up the NAS to automatically power off during the day, and power on in the evening. Now what happens is this: each time the NAS powers off, the network share disappears. After the NAS has turned on again, I have to manually re-connect to the network share.

My girlfriend uses Windows 7 to connect to the same share. For her, when the NAS is off, the network drive is still visible in "My Computer", albeit with a "not connected" marker. When the NAS is on, she simply opens the network drive and Windows notices that it is available again.

Is there a way to make Mac OS behave in a comparable way to Windows here? I want Mac OS to automatically reconnect to the drive when it is available again (or at least when I try to access it).

I know I can turn the connection into a login item, but I rarely re-login. I want this to work automatically, while already being logged in.

Jens Bannmann

Posted 2011-06-21T12:40:20.067

Reputation: 459

This has been bugging me for quite some time now. The thing is that you will probably get an error message like "The share has become unavailable" and the AFP mount disappears, right? – slhck – 2011-06-21T12:55:48.127

I'm not sure about the compatibility of the script with afp, but take a look at this question.

– viking – 2011-06-22T19:56:04.950

Answers

26

You will be able to get re-connect working with Autofs.

Apple has published a technical white paper on Autofs
http://images.apple.com/business/docs/Autofs.pdf

There is a comprehensive blog article by Rajeev Karamchedu
http://rajeev.name/2007/11/22/autofs-goodness-in-apples-leopard-105-part-i/

Also there is a third party application named AutomountMaker that enables this using GUI
http://jm.marino.free.fr/index.php?switch=sw_&title=AutomountMaker
(personally haven't used this software though)

Here is my setup using indirect mapping

(I personally use smb but afp should just work)

  1. edit master map file to add your custom map

    # sudo vi /etc/auto_master

    +add line

    /Network/NAS nas_map
  2. create /etc/nas_map add a following line

    # sudo vi /etc/nas_map

    +add line (note that you can add more than one line here)

    SHARE_NAME  -fstype=afp afp://USER:PASS@NAS_NAME/SHARE_NAME

    SHARE_NAME - directory name you want use to map /Network/NAS/SHARE_NAME
    USER:PASS - username and password (use 'guest' for anonymous login)
    NAS_NAME - name of your nas or the ip address
    SHARE_NAME - name of your share set by your NAS

    alternatively you can use following line to use smb instead of afp
    SHARE_NAME -fstype=smbfs ://USER:PASS@NAS_NAME/SHARE_NAME

  3. Set the permission on your map file

    # sudo chmod 600 /etc/nas_map
  4. Reload automount

    # sudo automount -vc

You now have access to your NAS via /Network/NAS/SHARE_NAME directory. When your server goes offline, you should be able to auto-connect to your NAS when it comes back online.

heesoo

Posted 2011-06-21T12:40:20.067

Reputation: 409

1Additionally, I dragged the icon of my share into the folder section of my Dock and set Dock Icon Option to Show as Folder and Show as List and get the Share triggered when I click into the Dock. – Marco M. von Hagen – 2015-06-19T14:53:50.573

You sir, are awesome. – bahamat – 2011-06-27T23:06:03.833