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

14

6

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?

Paul McMillan

Posted 2010-06-07T23:05:03.143

Reputation: 826

There isn't one. Disappointed me many times. – squircle – 2010-06-07T23:06:44.090

You've gotta be kidding me... no way to mount a DD image on OSX at all? It's friggin' BSD... – Paul McMillan – 2010-06-07T23:22:33.647

OSX file systems are HFS+ which is unique to Apple (They had to support old MacOS and so changed from the BSD system they had in NeXT). Note that this is all Unix complient – user151019 – 2010-06-08T10:31:32.587

Answers

9

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).

quack quixote

Posted 2010-06-07T23:05:03.143

Reputation: 37 382

I dd'd the whole drive. It's not a valid HFS+ image, as it includes a whole bunch of HFS+ partition tables, not just an image of the partition in question. Changing the file extension definitely doesn't do any good. It's also not formatted as an ISO image (headers and so on), nor is it a native mac img format (same problem). The disk utility will not mount the image at all. – Paul McMillan – 2010-06-08T00:07:15.240

1@paul: did you try the hdiutil command, or read the manpage? iso and img images don't have headers and so on; they're straight-up dd copies of partitions (so no partition tables as you'd get with dd'ing a whole drive). ISOs are called ISOs because they're often images of ISO-9660 filesystems used in data CDs. you should be able to use hdiutil. try running hdiutil imageinfo image-file-name to see if hdiutil recognizes your image as-is... hdiutil pmap image-file-name may also be useful to see if it recognizes a partition table in your image. – quack quixote – 2010-06-08T01:43:28.490

5@paul: the manpage gives this example for "forcing a known image to attach": hdiutil attach -imagekey diskimage-class=CRawDiskImage image-file-name – quack quixote – 2010-06-08T01:46:49.360

15

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.

krawyoti

Posted 2010-06-07T23:05:03.143

Reputation: 249

4

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.

Tim

Posted 2010-06-07T23:05:03.143

Reputation: 41

2

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".

Nick Klein

Posted 2010-06-07T23:05:03.143

Reputation: 21

2

Try using the .dmg file extension, as in dd if=/dev/disk1 of=MacintoshHD.dmg or similar.

This lets you double-click and mount the image in the Finder.

ThatGuy

Posted 2010-06-07T23:05:03.143

Reputation: 386