Page History

Auto-mount remote SMB volumes

Nigel Stanger edited this page on 23 Aug

Clone this wiki locally

sudo mkdir -p /System/Volumes/Data/mnt/shares

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.)

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.)

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 ☺️).