3

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 – Mark Oct 26 '13 at 16:29
  • What output do you see when using: hdiutil imageinfo Documents/OF.sparseimage? – Eddie Kelley Oct 26 '13 at 16:36
  • @EddieKelley Resource temporarily unavailable – DiTTiD Oct 26 '13 at 18:04
  • Is the disk image already attached? Try to unmount it, and then get image info... – Eddie Kelley Oct 26 '13 at 18:22
  • @EddieKelley I'm sure it's not already mounted ;) – DiTTiD Oct 27 '13 at 22:05
6

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 '13 at 17:18
  • As soon as I come back home I Try and I check. – DiTTiD Oct 27 '13 at 22:06
  • Perfect. This works!! :D – DiTTiD Oct 28 '13 at 13:14
  • 1
    This doesn't allow the user to specify the mount point. – Jason Jul 1 '14 at 16:42
4

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 .