Automount smb drive on OSX

automountmac-osxmount

I have been trying to achieve smb drive automounting on OS Sierra but I am unable to do it properly.

I hacked /etc/fstab which seems to work on this OS to the point that I am unable to force it to change ownership or chmod so other users than root can access it.

I seems that automount is ignoring all my attempts to set uid or gid for the mount and its always mounted as root:wheel.

I went through several threads that deal with that and found no solution anywhere so I tried using Automator with Applescript, where I used a command to Finder app that mounted drive for me, but it always asks for credentials so it's no use for me either.

Can anyone please provide working solution that mounts smb drive on OSx that's accessible for other users than root and works in headless mode (so it does not require any user to log in?)

Thanks

Best Answer

This works for me on macOS High Sierra:

  • Open Finder and press Command-K
  • Select your SMB share (I type "smb://NAS326/Storage" where NAS326 is an alias to the NAS IP address and Storage is the shared folder)

That mounts the SMB share and shows it in the desktop

  • Open System Preferences
  • Click on Users & groups
  • Select Login Elements
  • Drag&Drop the SMB share icon from desktop
  • Click on the box to hide it (should avoid to open a Finder window at each login)

Otherwise I could use the auto_master. I added this entry in /etc/auto_master (you need root access):

# Network Shares
/-          auto_smb    -nosuid,noowners

And then I created /etc/auto_smb:

/../Volumes/Storage -fstype=smbfs,soft,noowners,noatime,nosuid   smb://admin:password@NAS326/Storage

admin is the user allowed to read/write in my NAS and "password" is the password.

Also please note that the "soft" option is quite important. In case the resource is not available (network down or else) without it something in the OS may get stuck trying to connect to the resource.