u/Hely0n

▲ 40 r/unRAID+1 crossposts

I finally found a reliable way to mount SMB shares on macOS persistently and automatically, similar to how mapped network drives work on Windows, so I’m sharing it here in case someone else is struggling with the same thing.

This uses macOS’ built-in autofs, works after reboot, reconnects automatically, and doesn’t require any third-party apps or Finder login items.

1. Create a mount folder

mkdir -p ~/Network

You can name this folder whatever you want.
I originally used my server name there, but a more generic folder name felt cleaner in the long run.

2. Edit /etc/auto_master

sudo nano /etc/auto_master

Add this line:

/Users/<mac-username>/Network    <mac-username>.auto_smb

Example:

/Users/bob/Network    bob.auto_smb

3. Create your SMB map

sudo nano /etc/<mac-username>.auto_smb

Template:

<share-name>    -fstype=smbfs,nosuid,noowners ://<smb-username>:<password>@<server>/<share-name>

Example:

Archive    -fstype=smbfs,nosuid,noowners ://bob:PASSWORD@NAS/Archive
Media      -fstype=smbfs,nosuid,noowners ://bob:PASSWORD@NAS/Media

If your password contains special characters, URL-encode them:

@  -> %40
:  -> %3A
/  -> %2F

4. Secure the config file

sudo chmod 600 /etc/<mac-username>.auto_smb
sudo chown root:wheel /etc/<mac-username>.auto_smb

Example:

sudo chmod 600 /etc/bob.auto_smb
sudo chown root:wheel /etc/bob.auto_smb

Disclaimer: Keep in mind, that this password will be stored in plaintext on your system. This step doesn't encrypt it, it just makes sure that an attacker needs root to access it. As autoFS fails to access the keychain, there is no other way. I tried everything but ended up doing it that way, as it's a restricted user anyway and only LAN accessible.

6. Use your shares

Your SMB shares are now available under:

~/Network/<share-name>

Example:

~/Network/Archive
~/Network/Media

I used the Finder/login-item approach for about a year, but it was never really reliable, especially while roaming between different networks or after sleep/wake cycles.

So I started experimenting with autofs until I finally got a setup that seems stable and reliable so far.

One of my main use cases was centralized storage for our 3D printing models on a NAS. The issue wasn’t Bambu Studio itself, but macOS randomly losing the mounted SMB share. As soon as that happened, Bambu Studio would reset back to the default Downloads folder because the original network path no longer existed. Now it seems to work, even via VPN.

I hope this guide helps someone someday 🙂

EDIT: Originally, the password was stored in plaintext in the map file in Step 3. I found a way to use the system keychain! It must be added as an "internet password" to get picked up by autofs

EDIT EDIT: Somehow, the keychain-way stopped working after a reboot. I'm trying to fix it but maybe it was just caching luck... I restored the plain-text variant in the meantime.
If interested, see u/TheSoundOfMusak's comment for an approach with the keychain. It worked, but the shares will only be mounted when they are accessed and until that, they wont show up in the finder to access it (like using the -nobrowse flag)

reddit.com
u/Hely0n — 15 days ago