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.


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.

| improve this answer | |
  • 23
    Just in case anyone gets stuck here... this command will give you something like /dev/disk1. You can run hdiutil mount /dev/disk1 to actually see the files inside. It will print out the location of the mount point, something like /Volumes/Untitled – Sam Jan 30 '12 at 19:55

Doesn't the partition have a filesystem? Usually you mount it with something like mount -t ntfs /my/mountpoint/Partition1 /mnt

| improve this answer | |
  • thanks, this would be usually the way to go. however this would require /my/mountpoint/Partition1 to be a block device... It the same reason you cannot mount an iso by mount /path/to/iso /path/to/mountpoint – jan bernlöhr Aug 26 '10 at 18:26
  • 1
    Why not just make a memory-disk device that's file backed? Off the top of my head I think it's hdid /my/file and it will return a block device name. – Chris S Aug 26 '10 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.