Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

and

# vboxmanage createrawvmdk -filename /path/to/disk.vmdk -rawdisk /dev/sdX
share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

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)
share|improve this answer
    
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
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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