What disk image should I use with VirtualBox, VDI, VMDK, VHD or HDD?

Solution 1:

VirtualBox has

  • full support for
    • VDI
    • VMDK
    • VHD
  • partial support for
    • HDD (Parallels version 2 only)
  • and undocumented support for
    • QCOW
    • QED

Source: Oracle® VM VirtualBox® User Manual » Chapter 5. Virtual Storage » 5.2. Disk Image Files (VDI, VMDK, VHD, HDD)

Screenshot of Create Virtual Hard Disk


Answering Your Considerations

  • be able to use dynamic sizing

VDI, VMDK, and VHD all support dynamically allocated storage. VMDK has an additional capability of splitting the storage file into files less than 2 GB each, which is useful if your file system has a small file size limit.

HDD, QCOW, and QED have to be dynamically allocated if created in VirtualBox.

  • be able to have snapshots

VirtualBox supports snapshotting of all six formats.

  • be able to move my virtual machine to another OS or even another free virtualization solution with minimal effort (probably something that would run fine on Ubuntu).

VDI is the native format of VirtualBox. Other virtualization software generally don't support VDI, but it's pretty easy to convert from VDI to another format, especially with qemu-img convert.

VMDK is developed by and for VMWare, but VirtualBox and QEMU (another common virtualization software) also support it. This format might be the the best choice for you because you want wide compatibility with other virtualization software.

VHD is the native format of Microsoft Virtual PC. Windows Server 2012 introduced VHDX as the successor to VHD, but VirtualBox does not support VHDX.

HDD is a format for Parallels. Parallels specializes in virtualization for macOS. This probably isn't suitable for you, especially considering that VirtualBox only supports an old version of the HDD format.

QCOW is the old original version of the qcow format. It has been superseded by qcow2, which VirtualBox does not support.

QED was an abandoned enhancement of qcow2. QEMU advises against using QED.

  • performance

Each of the formats may have nuanced performance characteristics due to how the block storage is abstracted by the format, but I haven't found any benchmarks comparing the VirtualBox-supported formats.

There are bigger factors that influence performance, such as:

  • your physical device limitations (much more noticeable on a hard disk drive than a solid-state drive… Why?)
  • expanding a dynamically allocated virtual disk drive (write operations are slower as the virtual disk expands, but once it's large enough, expanding should happen less)
  • virtualization technology (hardware vs. software; hardware virtualization helps VirtualBox and improves the speed of virtual operating systems)
  • the fact that you are running a virtual operating system. Performance is always slower than running an operating system on the host because of the virtualization overhead.

Solution 2:

I always use VDI, as it is the native format of VirtualBox; however, using a VMDK (VMWare format) will increase compatibility with other virtual machine software.

VirtualBox will run fine on Ubuntu, so if the goal is Windows/Ubuntu interoperability, VDI would be a perfectly valid choice.

Both formats will fulfill your requirements.

As for the other two, VHD is a Microsoft-developed format, and HDD is an Apple-developed format; these are both proprietarily-licensed, so limit cross-platform support; I wouldn't recommend them.

Solution 3:

Mpack, explains a key performance difference between VHD and VDI here:

Having recently studied the VHD format, I would expect there to be at least a small difference in VDIs favor, most noticeable when you are comparing like with like, i.e. an optimized VDI vs optimized VHD. The reason is that the dynamic VHD format has these "bitmap" sectors scattered throughout the disk. Every time you modify a sector inside a block these bitmap blocks may need to be updated and written too, involving extra seeks, reads and writes. These bitmap sectors also have to be skipped over when reading consecutive clusters from a drive image - more seeks. The VDI format doesn't have these overheads, especially if the VDI has been optimized (blocks on the virtual disk sorted into LBA order).

All of my comments apply to the dynamic VHD format vs dynamic VDI. Performance tests on fixed sized virtual disks is pointless since both formats are then the same (just a plain image of a disk), they just have different headers on them.

https://forums.virtualbox.org/viewtopic.php?f=1&t=22688

Solution 4:

Looks like using VDI makes possible to trim disk file to its actual size VirtualBox and SSD's TRIM command support

Solution 5:

I don't know if using vmdk would enable you to transparently run a virtual machine created in VirtualBox in VMware or not. It might. However a more universal option might be to use the VirtualBox File/Export function to create an "Open Virtualization Appliance" .ova file that can then be imported into VMware. With that approach, you can port to any virtualization system that supports .ova without caring what disk image format you use in VirtualBox.

If you need to export from the same VM at regular intervals, e.g. every day, that could be a pain. But if you only move to a different technology occasionally, it should be fine.

If you have a .vdi file already, You can test whether this works without having to create a new virtual machine. Export it to a .ova, then try importing with vmware.