macOS will happily mount an SMB share from your NAS, and then just as happily forget it the next time your Mac wakes up, switches Wi-Fi, or your router blinks. Finder's "Connect to Server" doesn't reconnect, login items don't reconnect, and Apple has no built-in answer. Here are the options that aren't terrible.
TL;DR
- Want it to just work and you don't mind $10: AutoMounter from the Mac App Store. It's the most polished option, network-aware (can mount only on your home SSID or when your VPN is up), supports Wake-on-LAN, and handles sleep/wake automatically. Downside: no automatic retry if a mount disappears mid-session.
- Free and open source, no sudo, no daemons: MacMountSMB. A small shell-based installer that drops a LaunchAgent in
~/Library/LaunchAgents/and usesopen "smb://..."to mount on a schedule. MIT-licensed, fully reversible. - DIY, ~20 lines, no third-party code: a LaunchAgent that calls a tiny bash script using AppleScript +
osascript. This is what I'd reach for if I wanted to understand every piece. Full recipe below.
The problem, in one paragraph
SMB on macOS has two issues. First, the mount itself: when your network drops, your laptop sleeps, or you switch from Wi-Fi to ethernet, the mount goes stale and the kernel won't bring it back. Second, login items only fire on actual login — they don't react to network state. It's been broken for years and Apple has not prioritized it. The third-party and DIY options below exist because of that gap.
What to skip
- Login Items (Finder aliases dragged to Users & Groups → Login Items) — only runs on login, no reconnection. A user comment in the Ctrl blog survey called this out as the most common "why doesn't this work" trap.
- A bare AppleScript saved as an app — same problem. It fires on login, then sits there.
autofsvia/etc/auto_master— works, but the configuration is wiped by macOS updates. The Ctrl blog explicitly recommends against it unless you're an advanced user who keeps backups of/etc/.- Hardcoding your password in a script or plist — always store the credential in the macOS Keychain and read it at runtime with
security find-internet-password.
Option 1: AutoMounter ($10, Mac App Store)
This is the answer for most people. Install it, add your share, set your preferences. It mounts at login, on wake from sleep, and when network conditions change. The killer features:
- SSID-aware: only mount when you're on your home Wi-Fi, or only when your work VPN is up. Important on a laptop.
- Wake-on-LAN: can wake your NAS if it's sleeping before mounting.
- Menu bar indicator showing mount state.
Two real downsides: no free trial, and it doesn't retry a mount that disappears mid-session. If your network blips for ten seconds and the share drops, AutoMounter will notice on the next event but won't actively try to bring it back. For most home/lab setups that's fine.
Option 2: MacMountSMB (free, MIT)
PolakiniO/MacMountSMB on GitHub is the cleanest "small shell script that does one thing" option. Run the interactive installer, give it your server, share, and a label, and it drops a LaunchAgent in ~/Library/LaunchAgents/ that runs a check script on an interval. No sudo, no system daemons, no third-party binary — just shell and launchd. There's a status.sh and an uninstall.sh, and the whole thing is in ~/Library/Application Support/mountsmb/ if you want to read it.
Option 3: The DIY launchd agent (~20 lines)
This is the version I like, because every part is something you'd write yourself. The mount mechanism is AppleScript, which has two big advantages: it goes through Finder/Disk Arbitration (so diskutil unmount works cleanly), and it's silent — no auth dialog pops up.
Step 1: Store the credential in the Keychain
Open Keychain Access, add a new password item, or do it from the command line:
security add-internet-password \
-a yourusername \
-s nas.local \
-r "smb " \
-w 'yourpassword' \
-T /usr/bin/osascript
You only need to do this once. macOS will now hand the credential to osascript without prompting.
Step 2: The mount script
Save this as ~/bin/mount-nas.sh (or anywhere) and chmod +x it:
#!/usr/bin/env bash
set -u
# Returns 0 (mounted/healthy), 1 (down/failed).
SHARE="nas.local/Media" # server/share
MOUNT_NAME="Media" # /Volumes/Media
# Pull password from Keychain at runtime.
PASS=$(security find-internet-password -a yourusername -s nas.local -w 2>/dev/null) || exit 1
# If the mount is healthy, do nothing.
if [ -f "/Volumes/${MOUNT_NAME}/.liveness" ]; then
exit 0
fi
# Ask Finder to mount it. Silent, runs as your user, owned by your user.
osascript -e "mount volume \"smb://yourusername:${PASS}@${SHARE}\"" >/dev/null 2>&1
# Verify it actually came up.
[ -f "/Volumes/${MOUNT_NAME}/.liveness" ] || exit 1
exit 0
Create a tiny .liveness file on the share as a liveness check. (Any stable file will do — a folder, your Documents folder. The point is just to confirm Finder actually finished the mount.)
Step 3: The LaunchAgent
Save as ~/Library/LaunchAgents/com.you.mount-nas.plist:
<?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>com.you.mount-nas</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>/Users/you/bin/mount-nas.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>60</integer>
<key>StandardOutPath</key>
<string>/tmp/com.you.mount-nas.out</string>
<key>StandardErrorPath</key>
<string>/tmp/com.you.mount-nas.err</string>
</dict>
</plist>
Load it:
launchctl load ~/Library/LaunchAgents/com.you.mount-nas.plist
That runs the script at login and every 60 seconds. If the share is healthy, the script exits 0 in microseconds (the .liveness check). If it's down, Finder re-mounts it.
Why 60 seconds and not 5? Because the script's cheap, but you don't need to spam your NAS with mount attempts. 60s is a good default. If your network is stable, you could push it to 5 minutes. If your NAS drops constantly, drop it to 30s.
Optional: handle wake-from-sleep cleanly
The above will eventually catch a wake, but it can take up to 60s. If you want mounts to come back the instant you open the lid, install sleepwatcher via Homebrew and add ~/.wakeup:
#!/bin/bash
launchctl kickstart -k gui/$(id -u)/com.you.mount-nas
This restarts the agent on wake, which forces an immediate re-check.
Bonus: two real performance wins
Mounting reliably is half the battle. The other half is speed, and macOS's SMB client is famously chatty. Two tweaks from Arthur Rosa's excellent writeup actually move the needle:
1. Stop the Finder from littering your share with .DS_Store files
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
Log out and back in. Browsing large shares gets noticeably snappier.
2. Disable delayed TCP ACK
macOS still ships with TCP delayed ACK on by default, a holdover from the 10/100 ethernet era. SMB waits on those ACKs, so turning it off unsticks throughput. Test first:
sudo sysctl net.inet.tcp.delayed_ack=0
If it helps, make it permanent with a LaunchDaemon (also from that post):
sudo tee /Library/LaunchDaemons/com.startup.sysctl.plist > /dev/null <<'EOF'
<?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>com.startup.sysctl</string>
<key>LaunchOnlyOnce</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/sysctl</string>
<string>net.inet.tcp.delayed_ack=0</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOF
sudo launchctl load /Library/LaunchDaemons/com.startup.sysctl.plist
What I'd actually do
If you just want it to work and you'll spend ten dollars to make the problem go away: AutoMounter. If you'd rather have free and open source with a one-line installer: MacMountSMB. If you want to own the whole stack and have a debuggable, three-file setup: the LaunchAgent recipe above, lifted from Chris Dzombak's v2 script.
Whichever you pick, save the password to the Keychain, don't lean on Finder's "Connect to Server" login item, and turn off .DS_Store on network shares. That alone will make the experience feel less like fighting macOS.
Sources
- 5 options for auto-mounting network shares on MacOS — Ctrl blog
- AutoMounter — pixeleyes.co.nz
- MacMountSMB — GitHub (PolakiniO)
- SMBMounter — GitHub (KeepCoolCH)
- Keeping a SMB share mounted on macOS (and alerting when it does down) — Chris Dzombak
- Keeping a SMB share mounted on macOS (version 2) — Chris Dzombak
- Auto Mounting Network Shares on MacOS — r/MacOS (the
scutil -W -r/osascriptapproach from u/mdwstrn_potato_pants) - On macOS how do you make an smb volume mounted at boot — Ask Different
- SMB on Mac Sucks (but You Can Make It Better) — Arthur Rosa (WQ6E)
- Why does macOS have such a hard time keeping an SMB mount? — r/MacOS
- ConnectMeNow — Tweaking4All (free alternative mentioned in the survey)
- launchd.info (LaunchAgent/LaunchDaemon reference)