Using raw disk access with VirtualBox in Mac OS

By | November 23, 2013

For performance reasons, you may want to use a dedicated disk for your virtual machine.

This was not straightforward to do with VirtualBox on MacOS, so I decided to write it down and share it with others that may be interested.

In this example, we will use disk3 as raw device for a Windows virtual machine.

  1. Start by unmounting the disk you want to use:
    diskutil umountDisk /dev/disk3

  2. Then use the Disk utility GUI to create a new ms-dos style partitioned disk with 1 partition of type MS-DOS. Label it “WINDOWS”. The partition will be mounted automatically by default.
  3. Use vifs to configure Mac OS to not automatically mount this partition. The partition must not be mounted when using it with VirtualBox.
    LABEL=WINDOWS none  msdos  rw,noauto00

  4. Unmount the disk again
    diskutil umountDisk /dev/disk3

  5. Create a VirtualBox storage device:
    VBoxManage internalcommands createrawvmdk -filename /Users/perchrh/win7-raw.vmdk -rawdisk /dev/disk3

  6. Make the raw device accessible to the admin group:

    sudo chown root:admin /dev/disk3*
    sudo chmod 660 /dev/disk3*

  7. Use that disk (the vmdk-file) when creating the virtual machine in Virtualbox

That’s it!
Happy IO 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *