Skip to main content

raw disk access in VirtualBox

With VirtualBox being the only open source virtualization suite for MacOS X at the moment, I'm running it from time to time to test new stuff. Currently there's a two disk storage box standing at my desk and I wanted to attach both disks to a VirtalBox Guest OS. Although documented in the manual and in the blogosphere, I found it hard to find the (few) commands needed to do this:

darwin$ diskutil list
   #:                  TYPE NAME              SIZE       IDENTIFIER
   0:      GUID_partition_scheme             *931.5 Gi   disk3
   1:       Microsoft Basic Data              931.5 Gi   disk3s1

darwin$ VBoxManage internalcommands createrawvmdk \
            -filename disk0.vmdk -rawdisk /dev/disk3 -register
The resulting .vmdk file will only hold metadata but not contain any actual data - exactly what we want :-)

Oh, and while we're at it: disk performance sucks in MacOS X. IMHO, sequential read/write bandwidth from/to the raw device should only be limited by its HBA respectively the device attached to it. Well, this SATA disk (WD10EACS) is specified with 3Gb/s or ~375 MB/s and is attached via Firewire 800 which in turn should be able to deliver speeds up to 100MB/s. But under MacOS 10.5 (fully patched), dd only scores ~16MB/s. It's good to know though that the VirtualBox Guest OS (Linux 2.6) with raw access to this disk is receiving these 16MB/s as well, so no overhead here. Accessing the same disk on the same box (iMac, MB323LL/A) natively under Linux 2.6 gives us ~66MB/s - a far more reasonable number.