How do you mount network shares

Using several network shares here. On different machines (NAS and Linux servers). I like to have these shares always available on my Mac, so I’m using Bonjour/Avahi to make the shares discoverable.

Lately, basically since the Cataline upgrade, the Mac seems to lose connection to these avahi/samba shares after a while. The only way to restore the connection is to either manually mount the shares, or logout/login on the Mac.

This made me wonder how people are connecting to network shares. Are you using Bonjour/Avahi, a script or something else? Unfortunately macOS still doesn’t have an option to automatically connect to share on login. I know it can be done by adding something to the login items. But what I mean is a flag when connecting the first time, such as Windows had/has.

Long story short, how how do you connect your network shares to your Mac?

I’m using AutoMounter (available on the App Store), it keeps mounts alive and remounts disconnected drives when needed. Simple and beautiful, very happy with it, well worth the purchase.

2 Likes

Another vote for AutoMounter. I’ve been using it to automatically mount my Synology to my MacBook Pro when I’m home, and it has been flawless.

1 Like

I have written a variety of scripts in the past to do this, but having seen AutoMounter now, my advice (without having used it) is… get AutoMounter.

Because even my scripts didn’t work very well and I found them annoying. If this works, it’s well worth the price if this is something you’re doing often.

1 Like

I use AutoMounter to connect to some network shares when I’m on the office wifi and also highly recommend it.

1 Like

Thanks for all the recommendations for AutoMounter. I wasn’t aware of the application and checked it out.

While it surely looks very good and up to the task, I will make an attempt to build (part of) its functionality in Hammerspoon. First and foremost because I try to minimize the number of one trick pony utility applications and utilze the Swiss amy knife that is Hammerspoon as much as possible. That’s definitely to the easy way, and certainly not the fastest way to get up and running, but it’s a lot of fun and I tend to think it’s more efficient too.

Apart from the popularity of AutoMounter, it also got clear that Bonjour/Avahi is not very popular under MPU members. :wink: Which made me switch that off too, and go for the regular mounting (automated in some way or form that is).

I’ve written my own in Keyboard Maestro and Applescript. The trigger is a timer, so it fires off on whatever interval. The macro checks to make sure I’m on the correct wireless network (cancel if not), then checks that the NAS is reachable (cancel if not), it then goes through my list of shares and if they aren’t already mounted it will mount them.

The only remaining question on how I doit is “what it the appropriate interval?” I’m using 5m when I’m on my home network and 1m for work. I worry about wasting resources by doing it too frequently, but I haven’t had any problems with the 1m timing and I’ve used it with everything from a several years old Mac Mini to a brand new maxed out screamer iMac.

1 Like

That’s what I’m planning to make in Hammerspoon. Nice thing about HS is that is has a watcher for mounts. So if a disk gets unmounted, it can take the appropriate action. That saves a timer.

I purchased AutoMounter based on comments here. I hadn’t heard of it before.

It appears not to be able to manage connections of mounting/un-mounting USB drives? I’ve read their documentation and nothing mentioned, and nothing “discovered” by the app, and the protocol options don’t mention. Am I missing something?

I think I purchased without doing my normal due diligence! Maybe I’m wrong?!

USB disks are automatically mounted when you connect them to your computer. This discussion is about mounting network shares, which are disks on a remote computer/server/NAS. That’s a different thing indeed, as they don’t automatically mount.

If it was for mounting USB drives I’m afraid AutoMounter isn’t of much use to you.

2 Likes

That’s exactly how I do it. One thing though: how do you accomplish checking the availability of your NAS? That is something I am struggling with. :slight_smile:

Ping it’s IP address. If it is not available, the response will be an error code. If you find an error, don’t run the mount command. I’ve actually pulled that out as a Function to use in other macros. It returns the value FN_IP_exists as either TRUE or FALSE. KM doesn’t do boolean, so those values are just text. (I prefix macros that return values with FN_ and make them available globally, I do similar for SUB routines).

The action before this sets the initial value of FN_IP_exists to TRUE. The Execute AppleScript action then toggles it to FALSE if the device is not available.

tell application "Keyboard Maestro Engine"
	
	set AS_dest_ip to getvariable "KM_dest_ip"
	set AS_ip_exists to "TRUE"
	
	try
		do shell script ("ping -c 1 " & AS_dest_ip)
		
	on error
		set AS_ip_exists to "FALSE"
		setvariable "FN_IP_exists" to AS_ip_exists
		return
		
	end try
	
	--No need to set FN_ip_exists = TRUE here since that's already done before entering the script. Only needs to change if FALSE.
	
end tell
1 Like

Yep. Have to stop speed-reading!! My bad. :cold_sweat:

“I took a speed-reading course and read War and Peace in twenty minutes. It involves Russia.” Woody Allen

Another utility that does the trick is ConnectMeNow. I’m testing it right now and so far I like it. It’s free.

1 Like

I include my root user folder on my Synology NAS in my login user’s “Login Items” – “home” in the image below. Easy to do by clicking the + sign in the Login Items setup and selecting the device in “Network” under “Locations” in Finder. The first time the item is added, macOS asks which folder on the network drive to mount – so that’s why “home” appears in Login Items. But at boot time macOS actually mounts the whole drive (second image below). If I am off network, this fails silently.

mounts as

2020-05-12_06-20-56

Personally, I found this to be more reliable and less fussy than AutoMounter – YMMV depending on your local network.