I need to mount a .sparseimage from .bash_profile but I don't get how to do it. I tried:

alias of22='hdiutil attach "Documents/OF.sparseimage" -mountpoint "$HOME/OpenFOAM" > /dev/null ; . $HOME/OpenFOAM/OpenFOAM-2.2.0/etc/bashrc'

but this gives me:

hdiutil: attach failed - no mountable filesystem

if I double-click on it or I put it in Startup Items it works (but i need also to source the bashrc after the mount)

What's the problem?

  • Why > /dev/null - perhpas that output might give some info, also what is the error when you type just the hdiutil util in the e terminal and which directory are you in. ie break the command down into iys smaller pieces
    – mmmmmm
    Oct 26, 2013 at 16:29
  • What output do you see when using: hdiutil imageinfo Documents/OF.sparseimage? Oct 26, 2013 at 16:36
  • @EddieKelley Resource temporarily unavailable
    – rdbisme
    Oct 26, 2013 at 18:04
  • Is the disk image already attached? Try to unmount it, and then get image info... Oct 26, 2013 at 18:22
  • @EddieKelley I'm sure it's not already mounted ;)
    – rdbisme
    Oct 27, 2013 at 22:05

2 Answers 2


The open(1) command can do it:

/usr/bin/open /full/path/to/OF.sparseimage
  • Why downvote a correct answer? Did I miss something?
    – khowl
    Oct 27, 2013 at 17:18
  • As soon as I come back home I Try and I check.
    – rdbisme
    Oct 27, 2013 at 22:06
  • Perfect. This works!! :D
    – rdbisme
    Oct 28, 2013 at 13:14
  • 1
    This doesn't allow the user to specify the mount point.
    – Jason
    Jul 1, 2014 at 16:42

In fact, the command you use will mount the disk image, but there are two problems I see.

Before I get into those I want to clarify to all readers (as I had this problem), the following command will mount a disk image:

hdiutil attach image_name.sparseimage -mountpoint mount_point

where you specify image_name.sparseimage and mount_point to your liking.

Here are the problems with your specific case that I see:

1) You are not mounting it in the bash_profile. You are creating an alias. You must run the alias first to mount the disk image (with of22 in your case).

2) Seems like you've done #1 because you get the error message "no mountable filesystem". This is probably because the disk image is using a relative path, which means you must run of22 from the parent directory (which seems to be your home directory in this case).

Try changing the command to

hdiutil attach "$HOME/Documents/OF.sparseimage" -mountpoint "$HOME/OpenFOAM"

Notice the addition of "$HOME".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .