how to loop mount virtualbox disk images under linux

this info found at:
  • files must be VDI format

  • must be fixed size, not dynamic disk image

  • must contain a partition table (created by the virtual machine)

for this example, the disk image is file.vdi.

offdata =`VBoxManage internalcommands dumphdinfo file.vdi |
sed -ne 's/.*offData=\([0-9][0-9]*\)/\1/p'`
offset=`expr $offdata + 32256`
mount -o loop,offset=$offset