How do I mount a HFS+ dd image in OSX?

I had an HFS+ formatted drive that was going bad and wouldn't mount at all on OSX. I created an image using ddrescue on linux, and was able to save most of it.

I can mount the drive and see the data just fine in linux using this:

mount -o loop -t hfsplus dd_image mountpoint

This doesn't work on my OSX system since hfsplus isn't a valid filesystem type. If I try:

mount -t hfs image mountpoint

It complains that it needs a block device. What's the fix here?


Solution 1:

Hmm. According to one source, you need hdiutil (OSX hdiutil manpage), as in

hdiutil attach -readonly cdimage.iso

What you're trying to do is known as "loopback mounting", that is, mounting via the loop device. According to Wikipedia's article:

Mac OS X implements a native image mounting mechanism as part of its random access disk device abstraction. The devices appear in /dev as regular disk devices; reads from and writes to those devices are sent to a user-mode helper process, which reads the data from the file or writes it to the file. In the user interface it is automatically activated by opening the disk image. It can handle disk, CD-ROM or DVD images in various formats.

This suggests to me that your OSX system needs to recognize your image as a valid HFS image. Depending on how you created it (did you dd a partition or a whole drive?) you may be able to double-click on the image file, or you may need to give the file the right file extension (.iso or .img, perhaps). On Linux you could use the losetup command to associate the image file with a device like /dev/loop0 (mount -o loop does this for you, but OS X's mount manpage doesn't indicate any similar option).

Solution 2:

I confirm quack quixote's latest comment: the diskimage-class=CRawDiskImage setting allows an image created by dd to be mounted:

hdiutil attach -imagekey diskimage-class=CRawDiskImage image-file-name

P.S. I copied it here to give it more visibility.

Solution 3:

I know it is an old thread but this answer would of helped me an hour ago.

Both .DD and .DMG files are RAW image files. You can simply rename the image.dd file to image.dmg. If you have a series of files make sure you name them correctly. ie image.dmg, image.o1dmgpart etc.

Solution 4:

If you want to ensure the image isn't modified (i.e. if mounting for a forensic examination) be sure the use the -readonly option in your "hdiutil attach".