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

314

127

Latest versions of VirtualBox supports several formats for virtual disks, but they forgot to provide a comparison between them.

  • VDI
  • VMDK
  • VHD
  • HDD

Now, I am interested about a recommendation or comparison that considers the following:

  • be able to use dynamic sizing
  • be able to have snapshots
  • 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).
  • performance

sorin

Posted 2011-11-23T00:28:07.227

Reputation: 9 439

Performance wise, I think the best is to create fixed disks if you have the space. Otherwise it is very stressful on the OS when using the virtual machine instead of once at creation time. – Alexis Wilke – 2014-10-29T00:49:24.190

3Another thing to consider is resizing the image when you may need to - VBoxManage cannot resize VMDK's, so you'd have to clone to VDI first, then resize, then back to VMDK + fudge up the UUID. For this reason alone, VDI seems the better choice for me. – Mike Demenok – 2015-05-11T20:18:28.773

11Run Virtual box and click the help icon > Contents, there is a fair explanation in there under "Virtual Storage" – Moab – 2011-11-23T01:03:54.043

1Regarding migration to "another free virtualization solution... that would run fine on Ubuntu", I'm pretty sure VirtualBox is available for Linux. – Iszi – 2011-11-23T04:29:47.837

Answers

224

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 driveWhy?)
  • 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.

Deltik

Posted 2011-11-23T00:28:07.227

Reputation: 16 807

I think there is some missing consideration about raw host hard disk, that is the virtual guest using a "physical" hard disk (or RAID device) as seen from the host. This would allow for better performances than using a simulated drive over a filesystem. – EnzoR – 2016-06-03T15:17:42.870

1@Enzo: I use VMDK on a raw block device now. The big catch is that VirtualBox needs to run as root. Also, snapshots aren't supported on raw disks, but I have a third-party snapshotting system (ZFS). VMDK on a raw disk is also a lot less portable. As for performance, I don't have any solid benchmarks, but I don't have complaints either. – Deltik – 2016-06-03T15:59:01.313

6

VHD can be mounted as a drive in Windows Disk Management, which does not seem as straightforward with VDI: http://superuser.com/q/342334/13889

– endolith – 2016-09-27T16:57:20.843

5@msanford could you elaborate on how VMDK avoids backing up the enormous file - does rsync better able to figure out the differences? the VMDK file also seems change on every tweak. – Ben Creasy – 2017-06-18T18:46:59.993

VHD can be mounted on a Windows machine natively, though. – endolith – 2017-12-07T17:53:41.600

@msanford how do you avoid backing up monolithic VDIs? – Lucas Soares – 2018-10-10T21:02:29.247

@LucasSoares I use(d) VMDK. – msanford – 2018-10-11T12:42:01.113

@Deltik: it is not necessary to run as root, only as a user with write access to the raw disk file. On my system, disk block devices are owned by root/disk so putting your user into the disk group is enough. – Tom – 2020-01-02T11:39:54.243

19+1 I'll add that VMDK seems to offer the panacea I've been searching for in terms of incremental backups: I no longer have to back up an enormous, monolithinc VDI for a single bit change in the guest. – msanford – 2013-08-14T01:10:08.857

40

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.

Tortoise

Posted 2011-11-23T00:28:07.227

Reputation: 610

18

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

InterestedInHelping

Posted 2011-11-23T00:28:07.227

Reputation: 181

5

Disk image files reside on the host system and are seen by the guest systems as hard disks of a certain geometry. When a guest operating system reads from or writes to a hard disk, VirtualBox redirects the request to the image file.

Like a physical disk, a virtual disk has a size (capacity), which must be specified when the image file is created. As opposed to a physical disk however, VirtualBox allows you to expand an image file after creation, even if it has data already; VirtualBox supports four variants of disk image files:

VDI: Normally, VirtualBox uses its own container format for guest hard disks -- Virtual Disk Image (VDI) files. In particular, this format will be used when you create a new virtual machine with a new disk.

VMDK:VirtualBox also fully supports the popular and open VMDK container format that is used by many other virtualization products, in particular, by VMware.[25]

VHD:VirtualBox also fully supports the VHD format used by Microsoft.

Image files of Parallels version 2 (HDD format) are also supported.[26] For lack of documentation of the format, newer formats (3 and 4) are not supported. You can however convert such image files to version 2 format using tools provided by Parallels.

SRINIVAS

Posted 2011-11-23T00:28:07.227

Reputation: 51

3

This answer come's from Chapter 5 of the VirtualBox manual. link

– JerryOL – 2018-04-03T22:08:07.413

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.

Alan Meyer

Posted 2011-11-23T00:28:07.227

Reputation: 51

5

It depends on how you plan to use virtual disk as well. Not every VM wants a single partition on a single disk.

VDI seems to have more options (when used with VirtualBox), but as soon as you take VirtualBox out of the picture, support for VDI becomes somewhat shaky (as of late 2014).

For instance my solutions need to have maximum cross-platform support. Mounting a VDI (such as a loopback device) on linux or Windows 7 is harder and buggier than you might expect. Almost like the VDI has too many features, making it difficult to make fully conforming utilities that can operate on it.

VMDK is just less painless IMHO when you want it to work with any VM on any workstation, when you want to clone it 3 times to other systems on the network at the same time, and when you want to pry it open without launching a VM instance.

Even though I use VirtualBox 90% of the time, those few times when my disks become unaccessable in certain workflows have led me to favor VMDK for pluggable/shared filesystems.

user2097818

Posted 2011-11-23T00:28:07.227

Reputation: 480

4

A good reason for me for using vmdk is that Virtualbox (at least until v4.1) using VDI format has the tendency, over time, to fill the complete allocated disk space, even though the internal virtual disk usage is still much less. With Virtualbox using vmdk disks, this seems less of a problem.

But I'm talking years uptime. This might not be a problem many people encounter.

Ernest ter Kuile

Posted 2011-11-23T00:28:07.227

Reputation: 51

3It's more related to the fragmentation of the guest file system than to the format itself. – EnzoR – 2016-06-03T15:19:14.243

3

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

OwnageIsMagic

Posted 2011-11-23T00:28:07.227

Reputation: 131

While accurate it's a bit lackluster for a question that asks about the general differences between those formats, don't you think? – Seth – 2016-11-21T11:02:09.293

3@Seth General overview was provided by previous answers and I don't have enough rep to just comment, but it still important to mention this fact – OwnageIsMagic – 2016-11-21T13:32:54.923

1

Just as a suggestion though add it to give it more context. E.g. "While this answer provides a good overview, you should also consider the advantage of ...". So even if read alone your answer has a relation to a more general one.

– Seth – 2016-11-22T07:06:54.743

@Seth there is edit button under my question for you :D – OwnageIsMagic – 2016-11-23T01:16:27.660

Its a suggestion for you on how to improve the post. It's your decision whenever you want to do it as it is just my opinion. More or less rewriting a in an edit is rather bad style - again just my opinion. ;) – Seth – 2016-11-23T06:17:52.737

1I can guarantee, that i will review your edit, so your work won't be wasted. Also you will be mentioned as editor of question, so you will get proper attribution. What's the problem? – OwnageIsMagic – 2016-11-24T00:04:42.893

2

VDI is much easier to compact if the VM grows too large.

eych

Posted 2011-11-23T00:28:07.227

Reputation: 397

2

I just migrated a raw VMDK, which was mapped to a partition of a Transcend SSD370 128 GB to a Samsung Pro 850 512GB.

Apparently VMDK is a lot faster than VDI. I don't understand why, maybe I made a mistake somewhere.

I copied the VMDK via the Virtual Media Manager onto the 850. One time as a VDI, one time as a VMDK.

Then I ran hdparm -tT --direct /dev/sda on the images. For each of the "runs" I switched replaced the "Machine -> Settings -> Storage -> Controller SATA -> ImageFile.xxx". The raw partition on SSD370 was defined by a VMDK file, so it's not really an image.

These are the results:

################################################################################################

Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-96-generic x86_64)

  System information as of Thu Sep 21 17:02:51 CEST 2017

  System load:  1.96               Processes:              201
  Usage of /:   83.2% of 43.88GB   Users logged in:        0
  Memory usage: 4%                 IP address for eth0:    
  Swap usage:   0%                 IP address for docker0: 172.17.0.1

################################################################################################

======================================================================================
      V M D K --- R A W !!! --- on Transcend SSD370 128 GB
======================================================================================

 Timing O_DIRECT cached reads:   1024 MB in  2.00 seconds = 511.61 MB/sec <---
 Timing O_DIRECT disk reads: 1134 MB in  3.00 seconds = 377.88 MB/sec <---

 Timing O_DIRECT cached reads:   1042 MB in  2.00 seconds = 520.82 MB/sec <---
 Timing O_DIRECT disk reads: 1162 MB in  3.00 seconds = 387.27 MB/sec <---

---

 Timing O_DIRECT cached reads:   816 MB in  2.00 seconds = 407.55 MB/sec
 Timing O_DIRECT disk reads: 1020 MB in  3.01 seconds = 339.43 MB/sec <---

======================================================================================
      V M D K --- on Samsung Pro 850 515GB
======================================================================================

 Timing O_DIRECT cached reads:   836 MB in  2.00 seconds = 417.21 MB/sec <---
 Timing O_DIRECT disk reads: 782 MB in  3.01 seconds = 260.21 MB/sec

 Timing O_DIRECT cached reads:   834 MB in  2.00 seconds = 416.08 MB/sec
 Timing O_DIRECT disk reads: 786 MB in  3.00 seconds = 261.71 MB/sec

---

 Timing O_DIRECT cached reads:   826 MB in  2.00 seconds = 412.75 MB/sec <---
 Timing O_DIRECT disk reads: 774 MB in  3.00 seconds = 257.79 MB/sec

 Timing O_DIRECT cached reads:   828 MB in  2.00 seconds = 413.88 MB/sec <---
 Timing O_DIRECT disk reads: 774 MB in  3.00 seconds = 257.83 MB/sec

---

 Timing O_DIRECT cached reads:   842 MB in  2.00 seconds = 420.76 MB/sec <---
 Timing O_DIRECT disk reads: 770 MB in  3.00 seconds = 256.56 MB/sec

======================================================================================
      V D I --- on Samsung Pro 850 515GB
======================================================================================

 Timing O_DIRECT cached reads:   470 MB in  2.01 seconds = 234.21 MB/sec <---
 Timing O_DIRECT disk reads: 766 MB in  3.00 seconds = 254.94 MB/sec

 Timing O_DIRECT cached reads:   494 MB in  2.00 seconds = 246.45 MB/sec <---
 Timing O_DIRECT disk reads: 754 MB in  3.00 seconds = 250.92 MB/sec

 Timing O_DIRECT cached reads:   490 MB in  2.00 seconds = 244.46 MB/sec <---
 Timing O_DIRECT disk reads: 764 MB in  3.01 seconds = 254.03 MB/sec

################################################################################################
# Data above comes from here
################################################################################################

======================================================================================
      V M D K --- on Samsung Pro 850 515GB
======================================================================================

  System information as of Thu Sep 21 17:02:51 CEST 2017

user@xeon:~$ sudo hdparm -tT --direct /dev/sda
/dev/sda:
 Timing O_DIRECT cached reads:   836 MB in  2.00 seconds = 417.21 MB/sec <======
 Timing O_DIRECT disk reads: 782 MB in  3.01 seconds = 260.21 MB/sec <======

user@xeon:~$ sudo hdparm -tT /dev/sda
/dev/sda:
 Timing cached reads:   21080 MB in  2.00 seconds = 10554.40 MB/sec
 Timing buffered disk reads: 784 MB in  3.00 seconds = 260.92 MB/sec

user@xeon:~$ sudo hdparm -tT --direct /dev/sda
/dev/sda:
 Timing O_DIRECT cached reads:   834 MB in  2.00 seconds = 416.08 MB/sec <======
 Timing O_DIRECT disk reads: 786 MB in  3.00 seconds = 261.71 MB/sec <======

======================================================================================
      V M D K --- R A W !!! --- on Transcend SSD370 128 GB
======================================================================================

  System information as of Thu Sep 21 17:00:47 CEST 2017

user@xeon:~$ sudo hdparm -tT --direct /dev/sda
/dev/sda:
 Timing O_DIRECT cached reads:   1024 MB in  2.00 seconds = 511.61 MB/sec <======
 Timing O_DIRECT disk reads: 1134 MB in  3.00 seconds = 377.88 MB/sec <======

user@xeon:~$ sudo hdparm -tT /dev/sda
/dev/sda:
 Timing cached reads:   21182 MB in  2.00 seconds = 10603.52 MB/sec
 Timing buffered disk reads: 1060 MB in  3.00 seconds = 352.91 MB/sec

user@xeon:~$ sudo hdparm -tT --direct /dev/sda
/dev/sda:
 Timing O_DIRECT cached reads:   1042 MB in  2.00 seconds = 520.82 MB/sec <======
 Timing O_DIRECT disk reads: 1162 MB in  3.00 seconds = 387.27 MB/sec <======

======================================================================================
      V M D K --- on Samsung Pro 850 515GB
======================================================================================

  System information as of Thu Sep 21 16:58:12 CEST 2017

user@xeon:~$ sudo hdparm -tT --direct /dev/sda
/dev/sda:
 Timing O_DIRECT cached reads:   826 MB in  2.00 seconds = 412.75 MB/sec <======
 Timing O_DIRECT disk reads: 774 MB in  3.00 seconds = 257.79 MB/sec <======

user@xeon:~$ sudo hdparm -tT /dev/sda
/dev/sda:
 Timing cached reads:   22082 MB in  2.00 seconds = 11055.78 MB/sec
 Timing buffered disk reads: 788 MB in  3.01 seconds = 262.11 MB/sec

user@xeon:~$ sudo hdparm -tT --direct /dev/sda
/dev/sda:
 Timing O_DIRECT cached reads:   828 MB in  2.00 seconds = 413.88 MB/sec <======
 Timing O_DIRECT disk reads: 774 MB in  3.00 seconds = 257.83 MB/sec <======

======================================================================================
      V D I --- on Samsung Pro 850 515GB
======================================================================================

  System information as of Thu Sep 21 16:55:24 CEST 2017

user@xeon:~$ sudo hdparm -tT /dev/sda
/dev/sda:
 Timing cached reads:   21468 MB in  2.00 seconds = 10747.37 MB/sec
 Timing buffered disk reads: 662 MB in  3.01 seconds = 220.12 MB/sec

user@xeon:~$ sudo hdparm -tT --direct /dev/sda
/dev/sda:
 Timing O_DIRECT cached reads:   470 MB in  2.01 seconds = 234.21 MB/sec <======
 Timing O_DIRECT disk reads: 766 MB in  3.00 seconds = 254.94 MB/sec <======

user@xeon:~$ sudo hdparm -tT --direct /dev/sda
/dev/sda:
 Timing O_DIRECT cached reads:   494 MB in  2.00 seconds = 246.45 MB/sec <======
 Timing O_DIRECT disk reads: 754 MB in  3.00 seconds = 250.92 MB/sec <======

user@xeon:~$ sudo hdparm -tT /dev/sda
/dev/sda:
 Timing cached reads:   20872 MB in  2.00 seconds = 10448.98 MB/sec
 Timing buffered disk reads: 694 MB in  3.01 seconds = 230.78 MB/sec

user@xeon:~$ sudo hdparm -tT --direct /dev/sda
/dev/sda:
 Timing O_DIRECT cached reads:   490 MB in  2.00 seconds = 244.46 MB/sec <======
 Timing O_DIRECT disk reads: 764 MB in  3.01 seconds = 254.03 MB/sec <======

======================================================================================
      V M D K --- on Samsung Pro 850 515GB
======================================================================================

  System information as of Thu Sep 21 16:52:32 CEST 2017

user@xeon:~$ sudo hdparm -tT /dev/sda
/dev/sda:
 Timing cached reads:   20872 MB in  2.00 seconds = 10448.90 MB/sec
 Timing buffered disk reads: 764 MB in  3.01 seconds = 254.11 MB/sec

user@xeon:~$ sudo hdparm -tT --direct /dev/sda
/dev/sda:
 Timing O_DIRECT cached reads:   842 MB in  2.00 seconds = 420.76 MB/sec <======
 Timing O_DIRECT disk reads: 770 MB in  3.00 seconds = 256.56 MB/sec <======

======================================================================================
      V M D K --- R A W !!! --- on Transcend SSD370 128 GB
======================================================================================

  System information as of Thu Sep 21 16:29:55 CEST 2017

user@xeon:~$ sudo hdparm -tT /dev/sda
/dev/sda:
 Timing cached reads:   22034 MB in  2.00 seconds = 11029.82 MB/sec
 Timing buffered disk reads: 990 MB in  3.00 seconds = 329.68 MB/sec

user@xeon:~$ sudo hdparm -tT --direct /dev/sda
/dev/sda:
 Timing O_DIRECT cached reads:   816 MB in  2.00 seconds = 407.55 MB/sec <======
 Timing O_DIRECT disk reads: 1020 MB in  3.01 seconds = 339.43 MB/sec <======

I don't really know how to interpret this, maybe somebody wants to leave a comment on it. I chose the VMDK then.

Daniel F

Posted 2011-11-23T00:28:07.227

Reputation: 751

1

A long time ago i did one test, convert dynamic vdi into dynamic vhd just to test speed and file sizes.

Remember it was an inmutable Windows guest clean os install with some apps, remember for my test i convert one format to another, so both are suposed to have the exactr same image, like doing a cloning.

For a disk size of 64GiB, the VDI file size was arround 18GiB, while the file size of VHD arround 22GiB.

I can remember i saw theese two things:

  1. Boot time was significally different, if i do not remember bad vhd was 1.6 times faster than VDI
  2. VHD size was much bigger than VDI, arround 4GiB gigabytes bigger over a 18GiB, so 1.2 times bigger.

That was long time ago and test was done on an HDD, but i ensure both files where defragmented and next to each other on the fast part of the disk.

Hope someone can do real SSD tests, but my feeling is that VHD is faster (and bigger) than VDI.

Just a tip: VHD/VHDX can be compacted diretly on any Windows 7 and Up by using DiskPart command line tool, for VDI there is needed an external tool CloneVDI.

Sorry i did not test VMDK, i did not know how to compact it without changing its UUID (the disk UUID), remember VBOX command tools allways change it on every clone, no matter what format you use.

Laura

Posted 2011-11-23T00:28:07.227

Reputation: 11