Mount block file on OSX

loopbackmac-osxmount

How can block files be mounted on osx? I tried

hdiutil attach filename

however this is terminating with

hdiutil: attach failed - not recognized

hdiutil only seems to work for iso/dmg images. On ubuntu the block file can easily be mounted with

mount -o loop filename mountpoint

Background: I used vdfuse (http://forums.virtualbox.org/viewtopic.php?f=26&t=33355&start=0) to mount virtual disk files (e.g. vhd). vdfuse itself works fine and the partitions contained in the virtual disc appear as block files on the mount point.

VHD File -> /my/mountpoint/Partition1, Partition2, …

On ubuntu the block files can be mounted via

mount -o loop /my/mountpoint/Partition1

however the -o loop option does not exist on osx.

Best Answer

hdiutil was the right way to go but a crucial ingredient are the parameters.

The command

hdiutil attach -imagekey diskimage-class=CRawDiskImage -nomount filename

perfectly mounts the block file as a block file system. Afterwards you can mount any fs like Chris S pointed out.