Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nigel123

macrumors newbie
Original poster
Oct 23, 2012
21
0
Heya!

So I just set up a network hard drive for my family so that we can access files from any computer, or watch movies from the TV without any need to plug and swap each connection.

My issue is the initial connection to the HDD on start up, wake ups, and other reestablishments with the network.

I've looked into the issue and found many many solutions that don't work. What my problem is the way my HDD establishes connection with the router. It's slow. Takes about 1-2 minutes, while the computers take less that 30 seconds.

What is occurring is the computer starts up and goes, "Oh network isn't available," and then doesn't try to connect.

I found this guide: http://superuser.com/a/303011 but I don't really understand it. I've used terminal before, but after I enter the first line I don't see what should come next.

So what I'm really asking: Is there a way in OSX ML to automatically connect to a network HDD when it sees it is ready, rather than try and connect when it is clearly not available.

Additionally, please avoid "Leave the HDD and router on all the time" because that is not how we roll and if it were this question wouldn't be posed.
 

Weaselboy

Moderator
Staff member
Jan 23, 2005
34,482
16,197
California
We should be able to fix you up with an Applescript to mount the drive then put a delay XX command at the beginning of the script to delay it running.

What is the path to the network drive and I'll try and help you with the Applescript.
 

Nigel123

macrumors newbie
Original poster
Oct 23, 2012
21
0
Sorry I took so long!

We should be able to fix you up with an Applescript to mount the drive then put a delay XX command at the beginning of the script to delay it running.

What is the path to the network drive and I'll try and help you with the Applescript.

I wasnt notified and got busy to check here!

It's located at: /Network/NAS/Media

My concern is that is this script going to run only at login or will it always detect if the drive is online?

I would like it to be.. okay imagine you have a macbook, router, and nas hard drive. The power goes out, the macbook is fine because of battery, the router and has go out. Then the power comes on, you automatically reconnect to the router because your macbook is constantly checking for that connectivity. The hard drive however, is offline. My preference would be for it to say, "Oh I see the hard drive connected to the router I'll automatically connect" to "Oh it's offline I'll try and connect to see if it was interrupted" to "Oh it's definitely offline, no response" to hours later when it is online, "Oh I see it connected now, I'll list it in the connected severs".
 

Weaselboy

Moderator
Staff member
Jan 23, 2005
34,482
16,197
California
I wasnt notified and got busy to check here!

It's located at: /Network/NAS/Media

My concern is that is this script going to run only at login or will it always detect if the drive is online?

I would like it to be.. okay imagine you have a macbook, router, and nas hard drive. The power goes out, the macbook is fine because of battery, the router and has go out. Then the power comes on, you automatically reconnect to the router because your macbook is constantly checking for that connectivity. The hard drive however, is offline. My preference would be for it to say, "Oh I see the hard drive connected to the router I'll automatically connect" to "Oh it's offline I'll try and connect to see if it was interrupted" to "Oh it's definitely offline, no response" to hours later when it is online, "Oh I see it connected now, I'll list it in the connected severs".

Paste this into the Applescript Editor app and save it as an application, then add it to your login items. This will launch the script at login and delay 30 seconds before mounting the NAS drive. You can test it in Applescript Editor first to see if you need to extend the 30 seconds.

Also, manually mount the drive and select it in Finder then do a command-i and look at the path to make sure it matches the section in quotes.

This should get you the delay you want at startup.

As far as making sure the drive stays mounted, that is a bit more complex. OS X has a utility called autofs that can be used to monitor networked drive and remount them. I am only slightly familiar with it... so you will need to research how to cobble together that piece yourself.

Code:
delay 30
tell application "Finder"
	try
		mount volume "smb://Network/NAS/Media"
	end try
end tell
 

AndrewSBreck

macrumors newbie
Dec 7, 2013
2
0
Bump

Anyone built something like this?
I have a network server at home, and all I want is for it to automatically connect if it is available.

so basically:
if ({Volume} isAvailable && !Connected)
connect to {Volume}
 

dimme

macrumors 68040
Feb 14, 2007
3,265
32,173
SF, CA
When I startup my mac I also want to connect to my network drive. I just added it to the login items and it is always there. Now if you are having a problem because you share is not available right away, perhaps we should work on that problem. I use a mini server with a attached drive and the volumes are always available. So is you nas always available to the network?
 

moez

macrumors regular
Jun 6, 2007
109
0
Anyone built something like this?
I have a network server at home, and all I want is for it to automatically connect if it is available.

so basically:
if ({Volume} isAvailable && !Connected)
connect to {Volume}

Did you figure out how to do it?
 

CJM

macrumors 68000
May 7, 2005
1,582
1,168
U.K.
Thread necro, yay! After some Googling I found this thread. Would love to be able to do what was mentioned here:

if ({Volume} isAvailable && !Connected)
connect to {Volume}

I have my Time Machine disk image on a network drive, which requires manual mounting every time I'm in the office. Obviously, I forget quite often, leading to weeks between backups. Is this doable via Applescript? I have an alias of the disk image on my desktop, so it's simply a matter of mounting it when the network share is available.

I last touched Applescript on Mac OS 10.1, to write some silly prank back in my teens. I have no idea what I'm doing.
 

AZhappyjack

Suspended
Jul 3, 2011
10,183
23,657
Happy Jack, AZ
It’s not an automated solution, but it is pretty simple to remount the drive using Finder.

I have a public share on my Drobo-FS named "Public". To set it up to reconnect, do the following:

Open Finder.
Press CMD-K.
Enter the smb path in the dialog box (smb://Drobo-FS/Public).
Click the + button to add it to the list of devices.
Click the [Connect] button.

Now, when the drive gets unmounted, re-mounting is a simple as opening Finder and pressing CMD-K [enter]
 

Attachments

  • Screen Shot 2014-09-05 at 8.00.20 AM.png
    Screen Shot 2014-09-05 at 8.00.20 AM.png
    96.2 KB · Views: 948

mvmanolov

macrumors 6502a
Aug 27, 2013
858
5
Thread necro, yay! After some Googling I found this thread. Would love to be able to do what was mentioned here:

if ({Volume} isAvailable && !Connected)
connect to {Volume}

I have my Time Machine disk image on a network drive, which requires manual mounting every time I'm in the office. Obviously, I forget quite often, leading to weeks between backups. Is this doable via Applescript? I have an alias of the disk image on my desktop, so it's simply a matter of mounting it when the network share is available.

I last touched Applescript on Mac OS 10.1, to write some silly prank back in my teens. I have no idea what I'm doing.

You could automator to make a app that will automatically connect at login...
Pause (3sec)
get specified server
connect to server
done :D
 

CJM

macrumors 68000
May 7, 2005
1,582
1,168
U.K.
You could automator to make a app that will automatically connect at login...
Pause (3sec)
get specified server
connect to server
done :D

As a login app only, or can it be executed when entering password after waking from sleep? I don't really turn off my laptop.
 

mvmanolov

macrumors 6502a
Aug 27, 2013
858
5
As a login app only, or can it be executed when entering password after waking from sleep? I don't really turn off my laptop.

well, automator is quite powerful, so you may be able to do that. for example you can make the same app as a "service" and then create a "workflow" that will do that.... i may try this myself actually. LOL (though in the interest of full disclosure, i'm by no means an automator expert...)
 

AntonioMello

macrumors newbie
Nov 10, 2014
1
0
This is how I made it work here

Hi guys, this is what I have in AppleScript that was able to mount my network HD connected to an Airport Extreme. I didn't want to install a 3rd party app just to do this, so I researched a bit online and ended up with this working solution, hope it helps.

Open Apple Script Editor and insert the following (changing what's indicated in red), save it so you can edit it easily, then export it as an application.
Remove the lines in red when you copy to applescript, as they're just instructive:


This first line below creates a delay to start the script (in seconds), it allows your computer to connect to the wifi before the script is run. If you think you need to make it longer, just change 5 to the value you'd like.
delay 5

-- Check IP address is reachable

set IP_address to "192.168.0.17"
change the IP address above for your IP of your router (airport extreme in my case). Remember to setup your airport extreme to use this IP address as static, so it doesn't eventually change.

set IP_Valid to true

try
do shell script ("ping -c 2 " & IP_address)
on error
set IP_Valid to false
end try

-- PREPARING NETWORK CHECK (SSID)

set SSID to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk '/ SSID: / {print $2}'"

-- CHECK IF YOU'RE CONNECTED TO THE CORRECT NETWORK

if SSID is "Greta" or IP_Valid then
Change Greta for the name of your wifi network as it appears on your wifi monitor

-- MOUNTING DRIVE

mount volume "afp://YourUser:YourPassword@192.168.0.17/My%20Shared%20Folder"
On the above line, insert the user and password you use to connect to the network drive. Change the IP "192...17" for the IP of the router, same as you did some lines above. Change "My%20Shared%20Folder" for the folder you'd like to connect to on the remote disk. Notice that if you have spaces on the username, or folder name, change the spaces for "%20". If you don't need a user and password to access your HD, just remove the part "YourUser:YourPassword@" from the code above

-- SET RESULT VAR TO "GOT IT"

set endresult to "got it"

-- ELSE

else

-- DO NOTHING

-- SET RESULT VAR TO "FAIL"

set endresult to "fail"

-- END

end if


That's it. Now that you've exported it as an application, test it and you should see your drive mounted.

Now let's make this application run when your computer logs in. Go to System Preferences, Users & Groups, select your user, click the lock at the bottom left to allow changes, choose "login items", click the + button, find your application and your good to go. Just log out and in again, your driver should mount automatically after the specified delay time.

Still figuring out how to amend it so it runs on system wake, if anyone has an idea, it'd be great to know.

Cheers!
 

marxspawn

macrumors newbie
Mar 31, 2017
1
1
I am using a 4TB external hard drive connected to a wireless router via USB for Time Machine
This code did not work until I mounted the volume first, then attached the sparsebundle
Hope this helps
Code:
tell application "Script Editor"
    try
        tell current application
                                   -- First mount NAS Folder
            mount volume "smb://192.168.xx.xx/yourVolume/"
                                   -- Allow time to mount
            delay 20
                                   -- Now run script to attach Volume as a Drive
            do shell script ("hdiutil attach -mountpoint /Volumes/TimeMachine/ /Volumes/yourVolume/TimeMachine.sparsebundle")

        end tell
    end try
end tell
 
  • Like
Reactions: satcomer

blakey42

macrumors newbie
Oct 28, 2017
1
0
Heya!

So I just set up a network hard drive for my family so that we can access files from any computer, or watch movies from the TV without any need to plug and swap each connection.

My issue is the initial connection to the HDD on start up, wake ups, and other reestablishments with the network.

I've looked into the issue and found many many solutions that don't work. What my problem is the way my HDD establishes connection with the router. It's slow. Takes about 1-2 minutes, while the computers take less that 30 seconds.

What is occurring is the computer starts up and goes, "Oh network isn't available," and then doesn't try to connect.

I found this guide: http://superuser.com/a/303011 but I don't really understand it. I've used terminal before, but after I enter the first line I don't see what should come next.

So what I'm really asking: Is there a way in OSX ML to automatically connect to a network HDD when it sees it is ready, rather than try and connect when it is clearly not available.

Additionally, please avoid "Leave the HDD and router on all the time" because that is not how we roll and if it were this question wouldn't be posed.

Hey had this same issue and found an in the App Store called AutoMounter. Works great!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.