How to auto-mount USB disks attached to an Airport Extreme

Discussion in 'OS X Mountain Lion (10.8)' started by parish, Jul 28, 2012.

  1. macrumors 65816

    parish

    Joined:
    Apr 14, 2009
    Location:
    Wilts., UK
    #1
    I found this thread which explains how to have USB disks attached to an AEBS auto-mount at login.

    I created this script in AppleScript Editor

    Code:
    mount volume "afp://heathrow._afpovertcp._tcp.local/Iomega_HDD"
    mount volume "afp://heathrow._afpovertcp._tcp.local/TimeMachine"
    mount volume "afp://heathrow._afpovertcp._tcp.local/Vaults"
    and added it to my Login Items - but the disks don't mount.

    I've confirmed that the commands are correct as if I run it from the AppleScript Editor, the disks all mount correctly.

    The original thread was related to doing this on Leopard. Why should it not work on ML?
     
  2. macrumors 6502a

    btbrossard

    Joined:
    Oct 25, 2008
    Location:
    Chicagoland
    #2
    What about just adding the disk to the log in items?

    The "Remote Disk" is connected to the Airport Extreme.
     

    Attached Files:

  3. thread starter macrumors 65816

    parish

    Joined:
    Apr 14, 2009
    Location:
    Wilts., UK
    #3
    Yes, that works, but as it mentions in the link I posted, a Finder window opens for each mount, which is doubly annoying because there is quite a delay before it happens so you're in the middle of typing an e-mail when 3 Finder windows pop-up on top.
     
  4. macrumors 6502a

    btbrossard

    Joined:
    Oct 25, 2008
    Location:
    Chicagoland
    #4
    You could also use Automator to build an application that mounts the requested server volumes.

    I just created one to mount two server volumes on my network, and using Automator doesn't open finder windows when it runs at startup.
     

    Attached Files:

  5. thread starter macrumors 65816

    parish

    Joined:
    Apr 14, 2009
    Location:
    Wilts., UK
    #5
    Thanks, that works but since it's in Login Items it only works when I log in so the volumes don't remount when waking from sleep. Is there anyway to make this (or another) script run when on wake from sleep?
     
  6. macrumors 601

    brand

    Joined:
    Oct 3, 2006
    Location:
    127.0.0.1
    #6
    There are apps in the Mac App Store that will do this. Look there.
     
  7. macrumors 6502a

    Joined:
    Mar 12, 2010
    Location:
    Hilo, Hawaii
    #7
    I think mrichmon's answer a few years back is exactly what you're looking for to totally automate this in the background without any of the issues you're facing with other solutions.

    I'm just going to quote his (her) answer below:


    You'll probably want to look into Mac's fstab format a bit for guidance on substituting your AFP path in instead of using the UUID=xxxx-yyy-zzz format.

    This is the way to go, and how we manage mounting various network shares in general at boot time.

    - Don
     
  8. thread starter macrumors 65816

    parish

    Joined:
    Apr 14, 2009
    Location:
    Wilts., UK
    #8
    Ah, so OS X does look at /etc/fstab? I'm familiar with it from the Unix world, but there is no such file in OS X (at least on my system) so I assumed that it isn't used.

    So, is it a case of if it exists then it gets read and the contents executed, but the boot/system disk is mounted without needing an entry in /etc/fstab?

    So you recommend using afp:// rather than the UUID?
     
  9. macrumors 6502a

    Joined:
    Mar 12, 2010
    Location:
    Hilo, Hawaii
    #9
    Yeah,

    The line in his "step 2" causes Mac OS X to look at /etc/fstab after it's finished mounting the disks it normally mounts (system, firewire, usb, etc.)

    Code:
    sudo defaults write /Library/Preferences/SystemConfiguration/autodiskmount AutomountDisks
    A network drive won't have a UUID (only directly connected drives do.)

    The regular command line mount command for an AFP share looks like:

    Code:
    mount -t afp afp://username:password@server.local/directory mountpoint
    where:
    'username' is the authorized user for the share (if you have one)
    'password' is the password (again, if you have one)
    'server.local' is the name of the server, it can be an ip number instead.
    'directory' is the name of the afp shared directory
    'mountpoint' is the local path to where you're connecting the share.

    An example:
    Code:
    mount -t afp afp://don@timecapsule/files /Users/don/tc-files
    I think you can do the same thing inside your fstab file, although you need to use the fstab format shown by mrichmon. Something like:

    Code:
    afp://don@timecapsule/files    /Users/don/tc-files    afp     rw,auto 1   2
    I hope this helps.
     
  10. macrumors 6502a

    Joined:
    Mar 12, 2010
    Location:
    Hilo, Hawaii
    #10
    Actually, I found a much more definitive post that had full examples of using /etc/fstab for afp (airport/timecapsule) mounted disks.

    http://www.kristijan.org/2010/11/automount-afp-shares-in-osx/

    They have an example of an /etc/fstab line of:

    Code:
    192.168.0.109:/Media /Users/kristijan/Media url automounted,url==afp://kristijan:fakepass@192.168.0.109/Media /Users/kristijan/Media 0 0
    And also point out that you can use the "sudo automount -vc" to test your /etc/fstab file without rebooting.
     
  11. thread starter macrumors 65816

    parish

    Joined:
    Apr 14, 2009
    Location:
    Wilts., UK
    #11
    Don, that's great. Thanks for you help :)

    I'm away for a week now so won't be able to try it until I get back.
     
  12. thread starter macrumors 65816

    parish

    Joined:
    Apr 14, 2009
    Location:
    Wilts., UK
    #12
    @Don

    Had time to do this before I went away, but there are a couple of problems with the stuff you quoted:

    Firstly, the sudo defaults write ... command is truncated; it should be:

    Code:
    sudo defaults write /Library/Preferences/SystemConfiguration/autodiskmount AutomountDisks[b][COLOR="Red"]WithoutUserLogin -bool true[/COLOR][/b]
    Secondly, in the second link you posted, the /etc/fstab entry in that tutorial is wrong; he includes the mount point a second time, immediately before the dump flag - took me ages to spot it, but once I had, and removed it, it worked fine.

    The only problem with using the automounter is that the remote disks don't show up as mounted in Finder and if you click on them, Finder creates a second mount with `-1` appended to the mount point, e.g. Vaults-1, so you have the same share mounted twice on different mount points which I don't believe is a good thing. Hmm, more investigation needed I think...
     
  13. macrumors 6502a

    Joined:
    Mar 12, 2010
    Location:
    Hilo, Hawaii
    #13
    Awesome. Sounds like you made a lot of progress.

    I may fiddle around with this a little myself. Right now I'm mounting NFS shares via /etc/fstab, and it seems to work a little different.

    I didn't spot the 2nd mount point in the afp example from Kristijan either. You've got good eyes.

    We're creating a great reference thread for others here. I hope we can work out the kinks.

    Mrichmon used a mount point of "none" in his example. I wonder if that was to avoid the double mounting problem. Automounter is supposed to mount requested drives on demand using the info in /etc/fstab.

    I'll post if I figure something out that makes this work better.
     
  14. macrumors 68030

    Joined:
    Sep 21, 2011
    #14
    I've got a somewhat different problem... My iTunes library is located on an external drive which is connected to my Airport Extreme Base Station, and if I wake the computer from sleep via ATV - I never log on and I can't play anything on my ATV since the drive is not mounted until logon.

    Would trying to follow the steps discussed here help me with having the drive mount (or not unmount as the computer goes to sleep)?
     
  15. thread starter macrumors 65816

    parish

    Joined:
    Apr 14, 2009
    Location:
    Wilts., UK
    #15
    OK, I'm back from my travels to foreign parts and have looked into this more.

    This statement I made turns out not to be the case...

    Firstly, they won't show as mounted in Finder until you click on them. That is the whole point of the automounter; it's a daemon that only performs the actual mount on demand, i.e. when something attempts to access the drive, such as clicking on it in Finder.

    As for the duplicate mounts (with '-1' appended to the mountpoint name) this is not happening now, although it definitely was when I was playing around before. What I think happened to cause this was that I was testing multiple methods - AppleScript, Automator, and /etc/fstab - and if the disks had been mounted using AS or Automator, then unmounted in Finder, and remounted using the /etc/fstab entries via sudo automount -vc then the duplicates occurred, probably because the AS (or Automator) "held" the mountpoints (i.e. they still existed in /Volumes, even though nothing was mounted on them) thereby preventing the automounter using them.

    Once I'd disabled the AS and Automator, and rebooted, everything works as expected. So, the /etc/fstab is the way to go.

    Hope this helps :)
     

Share This Page