Automatically Connect to a Network Drive on Mac OS X Start Up & Login

May 4, 2012 - 29 Comments

A network drive in OS X

It can be helpful to configure Mac OS X to automatically mount shared network drives, this is particularly true for those of us who regularly connect to a network drive for file sharing or backups.


Setting up automatic network drive connections in OS X is a two-step process, you must mount the drive, then you add it to your automatic login items. This should work flawlessly in most versions of OS X, but we’ll cover an alternative approach that uses Automator to mount a network drive automatically on login as well.

1) Mounting the Network Drive

If you’re already familiar with mapping a network drive in Mac OS X you can skip the first part of this and go straight to System Preferences in the second section.

  1. From the OS X desktop, pull down the “Go” menu and select “Connect to Server”
  2. Connect to the server and mount the drive you want to automatically connect to on boot
  3. Choose Guest or for a specific user check the box next to “Remember this password in my keychain” – you must select to remember the password otherwise the automatic login event can not happen without logging into the network drive

Connect to a Network Drive

Next, you add the network drive to automatically connect on OS X by bringing it into your Login Items list.

2) Setting Up Automatic Connections to the Network Drive on Login

Once you are connected to the network drive we can set up automatic connections upon logging into the Mac:

  1. Open System Preferences and click on “Users & Groups”
  2. Select your user name from the list and then click the “Login Items” tab
  3. Drag & drop a mounted network drive into the login items list
  4. Optional: check the “Hide” box to keep the drives window from opening on each login and boot

Network Drive Icon This can be used to automatically connect to and mount SMB drives for those that need to share files with a Windows PC often, though you’ll need to enable SAMBA beforehand within File Sharing preferences.

Confirm the drive will automatically mount by logging out of the active user account and logging back in, or by rebooting the Mac.

Alternate: How to Enable Automatic Mounting of Network Drives on Login with OS X Automator

One of our readers pointed out in the comments a great trick that uses Automator to automatically mount network drives on Mac login. This is quite easy to setup as well, and if you’re having problems with the above method being reliable (like in OS X Yosemite), then this Automator method works very well:

  1. Launch Automator in OS X and create a new “Application”
  2. Drag “Get Specified Server” into the workflow, click “Add” and place the network drive network location address into the field
  3. Next, drag “Connect to Server” into the workflow
  4. Click on “Run” then login to the network drive as usual to verify that it works, choosing to save the login credentials
  5. Save the Automator application with a name like ‘Automatically Mount Network Drive Share’, and save it somewhere easy to locate like ~/Documents/ and then drag this into the Login Items list of OS X

Here is what this workflow in Automator looks like, click to enlarge:

Make an Automatic Network Drive Mounting app in Automator for Mac OS X

The next time the Mac logs in, that Automator Mount script will run and the network drive will mount as usual. This works very well, and I’m using it right now in OS X Yosemite. A big thanks to Dan for this automator trick!

If you want to stop this drive from automatically loading when you login or reboot the Mac, simply remove it (or the Automator app) from the automatic launch list in OS X and the network volume or network drive will no longer automatically connect any longer.

.

Related articles:

Posted by: William Pearson in Mac OS, Tips & Tricks

29 Comments

» Comments RSS Feed

  1. Nils Larsen says:

    Thanks for the Automator tip and procedure. It seems step 4 is invalid as there seems to be no option “to save the login credentials”, only “save to keychain” which does not seem to help (I don’t use keychain anyway). So, at login I have to enter the credentials for this to work unless I am missing something. Please advise if possible.
    I also am going to look into putting multiple drives that I wish to connect to at login. I presume this is fairly straightforward. Thanks again,
    Nils

  2. Kwasi says:

    It’s been quite some years but this trick is still working; however, I have another hard disk attached per USB on the main mountable one which is also mountable. So, what happens is that, because they are two disks attached to one, at system start a window pops up asking which one to mount and this is nerving me so much. Everything independently works well but now how do I get rid of that window pop up? Afterall, once that main HDD is mounted, the second attached to it is also mounted.

    • Kwasi says:

      Just resolved it with:
      afp://IPaddress/sharename

      There might be this afp://IPaddress:port number.

      Take of the port number and replace it with the folder sharename.

      afp://IPaddress/sharename

  3. Nick says:

    Anybody know why my script runs but still prompts for the password before the drives load? Thanks!

  4. Michael says:

    Anybody know why the drives still pop up after a reboot? I have the boxes checked to hide them.

  5. Sleurp says:

    Hi

    Can you tell me if the volume is unmount to finder but not in /Volumes.
    When you execute the script, you have /Volumes/xxx-01 and /Volumes/xxx-02 etc…
    Thank you very much !

    Have a nice day !

  6. iKomrad says:

    But what about keeping the drive mounted after you log in? Say your server reboots, your Macbook Pro goes to sleep and wakes up, etc. How can you make sure the the network drive stays connected when these things happen?

  7. Storm says:

    Doesn’t work for me. The Automator approach manages to bypass the returning login prompt but what happens is that the Automator app is started with the script ready to play instead of the script itself being run.

    I’m probably doing something wrong.

    • onmo says:

      Automator works to automatically connect to network drives, you are probably doing something wrong. Try again with following instructions, save it as an app, that goes into Login Items.

  8. Kevin Roa says:

    Thanks so much. I thought I was going to have to buy another hard drive.

  9. AWilson says:

    Thank you for this information. I used the OS X Automator instructions and that work great.

    I added a “pause” entry between “Get Specified Server” and “Connect to Server” of 10 seconds for 1st folder and 15 seconds for the 2nd folder. The pause was added because using WIFI to connect to the network shares would give an error message that it couldn’t connect to them.

  10. Paige says:

    When I go to click run, this message pops up:
    “The action ‘connect to servers’ encountered an error.
    Failed to connect to server ‘…..'”

    What do I do???

  11. I took this a step further and used Keyboard Maestro to set a wake trigger. My problem was that I rarely log out, just sleep. I wanted to mount to a trigger when I woke up my mac at work. I set the trigger for waking and looking for my work’s wireless network. Seems to work fine.

  12. Amanda says:

    Thank you so much

  13. David Kim says:

    The Automator version works much better on 10.10 for me.
    Thanks!!
    Thanks also for the launchd comment, that will be useful.
    D

  14. Ade says:

    Thanks for the advice – Automator works a treat and is really simple.

  15. Dan says:

    I use a simple Automator application i made. Simply drag get specified server into workflow, enter the address; afp://xx.x.x.x:548 then drag connect to server into the workflow. Run it to verify and then save as application. You can then set it to run at login from your System preferences.

    • Steve says:

      Dan’s simple Automator script is great. To mine I added the specific share hosted by the remote server. Its address looks like afp://myserver/fileshare. It could also look like afp://myserver:548/fileshare or afp://10.0.0.23:548/fileshare
      In any case, I (tested and) saved that script and then dragged it into Settings/Users&Groups/myusername/LoginItems. Thanks Dan!

      • Steve says:

        Almost six years later!

        • mathead says:

          So? I’m still reading here and obviously, so are you :)

          • ikomrad says:

            How do you keep it connected? The SMB network drive on my home Synology server disconnects by itself and I have into finder , click on the Synology server, and then double-click on the share name to reconnect it.

            Since I’m not at my computer all day, I wanted to avoid any solution that requires interaction from the user. It should quietly run in the background and keep drives connected.

      • sam says:

        It didnt work for me –
        I can connect to the server using >finder>go>connect to a server> afp://username:password@192.168.1.144 and it works

        But when I tried to create application using automator
        i get the following error
        The action “Connect to Servers” encountered an error.
        Failed to connect to server “afp://username:password@192.168.1.144”.

  16. James says:

    Has anyone seen when using this method the drive shows up multiple times on the desktop if you have them visible? Every login it increments by one on the desktop. I have found no viable way to stop this behavior.

  17. Fred says:

    Checking the “hide” box DOES NOT prevent the drive window from opening on boot/login. If only it were that easy – I’ve been searching for how to not have the window open, but only mount the drive for years (and through OS X 10.5, 10.6, and 10.7) now.

  18. Carlos says:

    For mounting on boot rather than login you must use a command line option

    – mount_ntfs

    – mount_smbfs

    – mount_msdos

    – mount_afp

    Stored as a LaunchAgent, ~/.launchd.conf, or set up with launchctl

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site