Automatically mount Sparsebundle?

Discussion in 'Mac Basics and Help' started by Namtaro, Nov 22, 2012.

  1. macrumors regular

    Joined:
    Dec 4, 2011
    #1
    Is there any way to do this?

    I have a sparsebundle on a fileserver that I use for timemachine backups and everything's great... it's just that I have to manually mount it every time I wake the macbook from sleep.

    I have tried dragging the sparsebundle into the login items, but that only mounts the shared harddrive and doesn't mount the sparsebundle itself.

    Any solutions would be awesome, thanks!
     
  2. macrumors P6

    Weaselboy

    Joined:
    Jan 23, 2005
    #2
    I think you could do it with the below shell script in an Applescript launched at login.

    Code:
    hdiutil attach -mountpoint ~/myMountPoint mySparsebundle.dmg
    
     
  3. thread starter macrumors regular

    Joined:
    Dec 4, 2011
    #3
    Sorry, I've never used Applescript before, any instructions to do so?
     
  4. macrumors P6

    Weaselboy

    Joined:
    Jan 23, 2005
    #4
    Okay. Start the Applescript editor from /Applications/Utilities and paste in the text below. Change extDriveName to whatever your external drive is called. Also change mySparsebundle.dmg to whatever you sparsebundle is called. Now click Run to test. If it works okay, go ahead and save the Applescript wherever you want. Documents folder is fine. Now add the Applescript to your login items. That should do it.

    Code:
    do shell script "hdiutil attach -mountpoint /Volumes/[I]extDriveName[/I] [I]mySparsebundle.dmg[/I]"
     
  5. thread starter macrumors regular

    Joined:
    Dec 4, 2011
    #5



    That's what I've written so far and it's turning up an error
    You said to change extDriveName to my external drive... but I do not have the sparsebundle on an external drive, but on a networked drive. That might be the problem?
     
  6. macrumors P6

    Weaselboy

    Joined:
    Jan 23, 2005
    #6
    Oh yes... that changes things. Follow this to mount the NAS at login then use the Applescript to mount the sparse bundle.

    Change the mountpoint /Volumes/extDriveName section to the NAS location. Look toward the bottom of the page I linked and you will also see a way to add the network mount to the Applescript.

    It is hard for me to do this without knowing what protocol you are using to share. If you post up the NAS share location, I'll try and string it all together into one script for you.
     
  7. thread starter macrumors regular

    Joined:
    Dec 4, 2011
    #7
    I"m using samba to share.

    The NAS share location is - smb://192.168.1.10/Timemachine
    The sparsebundle inside the shared location is - TimeMachine.sparsebundle

    Thanks a lot for the help so far. :)
     
  8. macrumors P6

    Weaselboy

    Joined:
    Jan 23, 2005
    #8
    Okay... try this in Applescript editor..

    Code:
    try
        mount volume "smb://192.168.1.10/Timemachine"
    end try
    do shell script "hdiutil attach -mountpoint smb://192.168.1.10/Timemachine TimeMachine.sparsebundle"
     
  9. Namtaro, Nov 25, 2012
    Last edited: Nov 25, 2012

    thread starter macrumors regular

    Joined:
    Dec 4, 2011
    #9
    Hmm, gave me a 'hdiutil: attach failed - No such file or directory' error.

    Used this and it looks to be working. Just added 'Volumes/TimeMachine/' before the sparsebundle
    Code:
    try
    	mount volume "smb://192.168.1.10/Timemachine"
    end try
    do shell script "hdiutil attach -mountpoint smb://192.168.1.10/Timemachine Volumes/TimeMachine/TimeMachine.sparsebundle"
    Do I save the Applescript somewhere and drag it into loginitems?
     
  10. macrumors P6

    Weaselboy

    Joined:
    Jan 23, 2005
    #10
    Excellent!

    Yes... just save as an Applescript where ever you want. Documents is fine. Then just add it as a login item. All set. :)
     
  11. Namtaro, Nov 25, 2012
    Last edited: Nov 25, 2012

    thread starter macrumors regular

    Joined:
    Dec 4, 2011
    #11
    Hmm, seems it doesn't work. When I save the script and add it as a login item, it only opens the script and doesn't actually run it. I have to manually press 'run'. :(

    Nevermind, found the solution - I had to export it as an Application :)

    Thanks for all the help, Weaselboy!
     

Share This Page