Pros and cons with this two ways to make disk for virtual machines on virtualbox

$ vboxmanage createhd --format VDI --size ${SIZE} --filename /path/to/disk.vdi


# vboxmanage createrawvmdk -filename /path/to/disk.vmdk -rawdisk /dev/sdX

File-pro (which are raw cons):

  • Will be cached by the operating system if they fit into ram
  • Easier to handle in VirtualBox (i.e. to resize raw you have to recreate the vmdk)
  • You might be able to use sparse-files (not sure)

Raw-pro (which are file cons):

  • You can use LVs here, giving you full flexibilty
  • Access should be faster, since it does not have to pass the filesystem-layer
  • Easy to handle outside VirtualBox (e.g. you could use LV-snapshots)
  • raw partitions have advantage over files in Because They avoid file system layers. how i can test this? – rkmax Dec 5 '12 at 21:50
  • @rkmax You could use exactly the same partition either in raw-mode, or put your image there on a filesystem. With an identical VM (just different disk) you should be able to see a small difference when doing a performance-check for disk-io within the VM. You should use a random write pattern. I expect read-performance to be better in a FS-based image if it fits into the cache of the host, though. – Nils Dec 6 '12 at 21:27

These are my hdparm -tT timings on a 4x1TB software raid setup running Ubuntu 12.04.1 as the host.

VM with VDI format:

Timing cached reads: 23442 MB in 1.97 seconds = 11890.47 MB/sec

Timing buffered disk reads: 346 MB in 3.00 seconds = 115.33 MB/sec

VM with rawdisk format (50G LV on the same raid device):

Timing cached reads: 21602 MB in 2.00 seconds = 10812.49 MB/sec

Timing buffered disk reads: 186 MB in 3.02 seconds = 61.69 MB/sec

So rawdisk is about 50% worse performance that VDI, unless I'm doing something completely wrong. Probably going to stick with rawdisk though as the backup option with lvm snapshots seems sane.

  • 2
    +1 for doing the tests, but I am puzzled by the results. – gogoud Nov 26 '15 at 14:55
  • 2
    If this is due to caching, it is an indication that you may lose plenty of data on a power outage. Far beyond what a journaling filesystem could recover. – Daniel F Nov 1 '16 at 23:56

The reason why VDI is faster is the OS cache the image file. And the I/O operations are buffered in the memory.

It would be more fair if you can close the cache function in virtualbox for this benchmark.

  • Why you should disable caching? An enabled cache would be the real life measurement.. – benba Nov 24 '17 at 14:10

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.