1

Is it possible to mount a network drive to my Mac server on boot, without requiring a login? I have one setup to mount on login via an automator script that I have added to the login items for the user account, which works fine.

The reason is I don't want to have to login to the Mac server, just to mount the network drive.

  • Once time I made an account to mount drives and then log out and set that to auto log in. This might be a nicer solution if there's a way to script this. – bmike Dec 19 '16 at 20:45
  • What's the purpose of the share mounted to the server machine? – klanomath Dec 19 '16 at 23:49
2

Simply create a launch daemon with the purpose to mount a remote share:

  1. Create a mountpoint:

    sudo mkdir -p /Shares/mntpoint1
    
  2. Add a launch daemon in /Library/LaunchDaemons:

    sudo nano /Library/LaunchDaemons/local.mount.extvol.plist 
    

    with the content:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Label</key>
        <string>local.mount.extvol</string>
        <key>ProgramArguments</key>
        <array>
            <string>/sbin/mount_afp</string>
            <string>afp://user:password@remotehost/share/</string>
            <string>/Shares/mntpoint1</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
    </dict>
    </plist>
    
  3. Load the daemon with

    sudo launchctl load /Library/LaunchDaemons/local.mount.extvol.plist 
    

The remotehost and share have to exist and the user has to have permissions to access the share with the password. The user doesn't have to be root!

The share will be loaded with root:wheel 700 permissions.

  • The solution provided by @klanomath doesn't work for me. When I load it with the command it works alright, but it doesn't work when I reboot. The log files doesn't state anything meaningful apart from an "error 51". I've tried a much simpler script with "touch" to create an empty file and it works alright, both when I start it from terminal and when I reboot. This is an important thing for me because I want to move my user directory to my NAS, but if I can't mount the network share before I log in everything breaks (as it rightfully should). I'm on High Sierra 10.13.6 – Luca Jan 6 '19 at 17:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .