How do I mount a sparsebundle to a folder rather than an image?

I have a encrypted sparsebundle and I want to mount to to a folder in my home directory and not under /Volumes. How can I do that?


Solution 1:

The hdiutil command-line utility gives you more flexibility, and is extensively documented in man hdiutil. Something like this should do:

hdiutil attach -mountpoint ~/myMountPoint mySparsebundle.dmg

Solution 2:

You might also be interested in http://blog.marc-seeger.de/2011/02/06/encrypted-diskimages-in-osx/ which explains step by step how to set up auto-mount to the specified mount point:

  • run mount to identify the disk device (/dev/diskNsN usually)
  • run diskutil info /dev/diskNsn | grep UUID to get the UUID
  • use sudo vifs to add a line to /etc/fstab

    UUID=whatever-you-noted-before /path/to/mountpoint hfs rw 1 0
    
  • Add your disk image to your login items to have it automatically mounted on /path/to/mountpoint at the next login