Page History

Auto-mount remote SMB volumes

Nigel Stanger edited this page on 28 Feb

Clone this wiki locally

Note that / has been read-only since Catalina, but this didn’t affect things until a security update in May 2021 deleted the /mnt symlink. It’s … difficult but not impossible to re-create that, but but it’s much easier to just point directly to the original location, and automount doesn’t care. (I seem to remember there being some problem with using a static mount point in /Volumes, as suggested in https://apple.stackexchange.com/a/261810, but I can’t recall the details.)

Pre-Catalina initialisation: sudo mkdir -p /System/Volumes/Data/mnt/shares

Post-Catalina initialisation: Use synthetic.conf to recreate /mnt as a firmlink (https://derflounder.wordpress.com/2020/01/18/creating-root-level-directories-and-symbolic-links-on-macos-catalina/):

# note: tab-delimited, reboot to take effect
mnt /System/Volumes/Data/mnt/shares

Add the following to /etc/auto_master:

/System/Volumes/Data/mnt/shares    auto_shares    -nosuid,noowners

(This change is likely to be clobbered by system updates, especially from Catalina onwards.)

Then in auto_shares (permissions 400):

username    -fstype=smbfs,soft ://username:password@registry.otago.ac.nz:/obs/obsuser/username
infosci-shared    -fstype=smbfs,soft ://username:password@registry.otago.ac.nz/obs/obsdept/infosci/shared
infosci-software    -fstype=smbfs,soft ://username:password@registry.otago.ac.nz/obs/obsdept/infosci/software
lecture-dropboxes    -fstype=smbfs,soft ://username:password@storage.hcs-p01.otago.ac.nz/its-alldropboxes
# "V2" may differ, "u" is the first letter of the username. Check under Windows to get the actual path.
staff-desktop    -fstype=smbfs,soft ://username:password@registry.otago.ac.nz/mdr/Profiles-V2/u/username
...

(This file is not known to macOS, so it should generally survive system updates.)

Note: If you are already logged into the machine with the corresponding domain account, then the password shouldn’t be needed as you are already authenticated. The username is still necessary (i.e., … ://username@registry.otago.ac.nz:/…). This means the file doesn’t need to be locked down as severely as it does if it contains passwords. Update: It might be necessary to manually mount all the shares first to ensure that credentials are cached or something. I had one share that stubbornly refused to mount until after I had manually mounted it first (and managed to reproduce the same effect with others later). It seemed to be happy once I had done that.

Reload configuration with sudo automount -vc.

See also https://apple.stackexchange.com/a/261813 for a more sophisticated version using a script.

Ensure that the mount point is not indexed by Time Machine. I suspect that this tickles the shares inside the folder, which seems to result in them being mounted over and over again until anything filesystem related grinds to a halt (the most I’ve seen is about 2300 mounts!). This appears to be a known problem under Catalina anyway; see https://discussions.apple.com/thread/250752057 for further discussion and a quick fix without having to reboot (TL;DR: disable the automount in auto_master, reload configuration, then umount repeatedly on anything remaining until it’s had enough ☺️).