VMware ESXi and vSphere Cluster Management
VirtualBox Disk Image Files: Formats, Fixed Disks, and Dynamically Allocated Disks
Learn how VirtualBox disk image files work, compare VDI, VMDK, VHD, and HDD formats, and choose between fixed-size and dynamically allocated virtual disks.
A VirtualBox virtual machine (VM) needs storage for its operating system, applications, and files. Instead of giving the guest operating system direct control of a physical drive, VirtualBox usually stores a virtual hard disk as one file or a set of files on the host computer.
How virtual disk image files work
The host is the physical computer and operating system running VirtualBox. The guest VM is the operating system and virtual machine running inside VirtualBox. A virtual disk image is a host-side file or set of files that provides a virtual hard disk to the guest.
From the guest operating system's perspective, the image behaves like a normal hard disk. When the guest performs a read or write, VirtualBox redirects that request through the VM's virtual storage controller to the disk image stored on the host's physical storage.
This creates two different storage measurements:
- Logical capacity: the maximum disk size presented to the guest, such as 80 GB.
- Host storage consumption: the physical space currently occupied by the image file on the host.
These values can be different. A guest may see an 80 GB disk while its image initially consumes only a few gigabytes on the host.
Virtual disk capacity and allocation
When you create a virtual disk, you assign it a maximum logical capacity. This is the size that the guest operating system will detect and use for partitions and file systems.
VirtualBox can provide that capacity using two broad allocation models:
- Thin provisioning: host storage is allocated gradually as guest data is written. Dynamically allocated disks use this model.
- Thick provisioning: the full configured capacity is allocated in advance. Fixed-size disks use this model.
For example, an 80 GB dynamically allocated disk can begin as a much smaller host file and grow toward 80 GB. An 80 GB fixed-size disk reserves or creates the full 80 GB during creation.
VirtualBox disk image formats
The allocation method and the image format are separate choices in many workflows. For example, you can create a VDI that is dynamically allocated or a VDI that is fixed size. You may also use an existing VMDK or VHD created by another virtualization product.
| Format | Full name or origin | Primary interoperability use | Typical reason to choose it |
|---|---|---|---|
| VDI | VirtualBox Virtual Disk Image | Native VirtualBox storage | Use when the disk will primarily remain in VirtualBox and no other platform requires a different format. |
| VMDK | VMware virtual disk format | VMware and cross-platform virtualization workflows | Use when attaching or exchanging a disk with VMware-based environments. |
| VHD | Microsoft virtual hard disk format | Microsoft virtualization and compatibility workflows | Use when an existing disk comes from a Microsoft virtualization environment or requires VHD compatibility. |
| HDD | Parallels version 2 disk image format | Parallels-related disk exchange | Use when working with a compatible existing Parallels version 2 image. |
Choose a format according to interoperability, migration needs, and the virtualization product that originally created the disk. VDI is a practical default for a new VirtualBox-only VM. An existing VMDK, VHD, or HDD may be preferable when importing or attaching a disk instead of reinstalling its guest operating system.
Dynamically allocated virtual disks
A dynamically allocated disk starts with a small host footprint and expands as the guest writes data. It can grow only up to its configured maximum virtual capacity.
Suppose you create an 80 GB dynamic disk for a development VM. The guest sees an 80 GB disk, but the host image may initially use much less. As the guest installs packages, stores source code, and creates data, the image grows.
Benefits and limitations
- It conserves host storage when the guest uses only part of its virtual capacity.
- It is useful when the guest's eventual storage usage is uncertain.
- Creating the disk is usually quicker because the entire maximum capacity does not need to be allocated immediately.
- Frequent growth events can add overhead and may affect write performance while new host storage is being allocated.
- The host must still have enough free space for future growth.
- Deleting files inside the guest does not necessarily make the host image file shrink automatically.
Guest free space and host file size are not the same thing. When a guest deletes a file, the guest file system marks those blocks as available, but the disk image may retain the host space it previously acquired. Compaction may be possible in an appropriate workflow, but take a backup and verify the prerequisites before attempting it.
Fixed-size virtual disks
A fixed-size disk is created at its full configured size. If you request a 60 GB fixed disk, VirtualBox reserves or creates that capacity during disk creation rather than waiting for the guest to use it.
- Creation can take longer, especially for large disks or slower host storage.
- Host storage consumption is predictable from the beginning.
- Write behavior can be more predictable because repeated expansion is not required.
- The host immediately commits space that the guest might never use.
Fixed allocation can suit a repeated lab, benchmark, or other workload with known storage requirements. Its main cost is the immediate reservation of host space.
| Characteristic | Dynamically allocated | Fixed size |
|---|---|---|
| Initial host space used | Starts smaller and grows with guest writes. | Full configured capacity is allocated or created at creation time. |
| Maximum guest-visible capacity | The configured maximum, such as 80 GB. | The configured maximum, such as 60 GB. |
| Creation time | Usually shorter because allocation is gradual. | Can be longer because capacity is allocated up front. |
| Growth behavior | Expands toward the maximum as data is written. | Does not need to expand during normal use. |
| Write-performance considerations | Growth events can add overhead, particularly when frequent. | Allocation behavior is more predictable after creation. |
| Risk of unused host-space reservation | Lower initial reservation, but future growth can be unexpected. | Higher because unused capacity is committed immediately. |
| Best-fit workloads | Test VMs, development environments, many VMs, or uncertain usage. | Known storage requirements, repeated labs, and workloads prioritizing predictable behavior. |
Choosing an allocation method
Choose a dynamically allocated disk when host capacity is limited, you need many test VMs, or you do not know how much storage the guest will eventually consume. This avoids committing the full maximum capacity at creation time.
Choose a fixed-size disk when storage requirements are known and predictable allocation or consistent behavior matters more than conserving initial host space. Allow extra time for creation and ensure the host can provide the entire requested capacity.
Always check host free space for both choices. A dynamic disk reduces initial usage, but it can grow unexpectedly. The combined maximum capacity of several dynamic disks can be much larger than the host's available storage.
Planning example
| VM | Configured virtual capacity | Current host file use | Allocation type | Remaining host free space | Planning concern |
|---|---|---|---|---|---|
| One dynamically allocated VM | 80 GB | About 20 GB initially | Dynamic | Host free space minus current image use | The image can grow by roughly another 60 GB as the guest fills the disk. |
| One fixed-size VM | 60 GB | About 60 GB from creation | Fixed | Host free space immediately decreases by about 60 GB | Space is predictable, but some capacity may remain unused. |
| Several dynamically allocated VMs | 60 GB each, for example | Small at first, then increasing | Dynamic | Can fall rapidly as guests grow | Their combined possible growth can fill the host even if every image initially appears small. |
Creating and attaching virtual disks
A disk image is not useful to a VM merely because the file exists. It must be attached to a virtual storage controller, the VM hardware component through which the guest accesses the disk.
VirtualBox storage workflows commonly involve three different actions:
- Create a new disk image: choose a format, allocation method, maximum capacity, and storage location, then install or use a guest operating system on it.
- Attach an existing image: connect an already-created VDI, VMDK, VHD, or compatible HDD to a controller in an existing VM.
- Import a disk from another platform: use an image created elsewhere, then verify its controller, firmware, boot, and guest hardware settings.
Graphical interface workflow
- During VM creation, choose to create a virtual hard disk, or open the VM's storage settings to add one.
- Choose an available image format, such as VDI, VMDK, VHD, or HDD.
- Choose dynamically allocated or fixed-size storage.
- Set the maximum virtual capacity.
- Attach the disk to an appropriate virtual storage controller.
VBoxManage examples
The following command creates an 80 GB dynamically allocated VDI. The --size value is in megabytes in this example, so 81920 represents 80 GB.
VBoxManage createmedium disk --filename "~/VirtualBox VMs/example/example.vdi" --format VDI --size 81920 --variant Standard
To request a fixed-size VDI instead, use the fixed variant:
VBoxManage createmedium disk --filename "~/VirtualBox VMs/example/example-fixed.vdi" --format VDI --size 81920 --variant Fixed
Exact command options can vary by VirtualBox release. Check the help output for the installed version before using the command in an automated workflow.
To attach an existing disk, the storage controller name must match a controller configured for the VM:
VBoxManage storageattach "Example VM" --storagectl "SATA" --port 0 --device 0 --type hdd --medium "/path/to/disk-image.vdi"
Replace the VM name, controller name, path, and filename with values from your system.
Troubleshooting disk image problems
The host drive becomes full
Dynamic allocation does not prevent host exhaustion. Multiple guests may expand as they receive updates, packages, and user data. Snapshots and other VM image files can consume additional space.
- Check host free space and the actual sizes of VM disk-related files.
- Plan for likely combined usage, not just the initial image sizes.
- Remove unneeded guest data and VM artifacts only after confirming they are safe to remove.
- Move VM storage to a larger host volume or reduce the number of concurrently growing VMs.
A fixed-size disk takes a long time to create
This is normally expected. VirtualBox is allocating the requested capacity immediately. Large disks and slow host storage increase the wait. Use a dynamically allocated disk when faster creation and lower initial host usage are more important.
An imported VMDK, VHD, or HDD will not attach or boot
The image may depend on controller, firmware, or VM hardware settings from its original environment. Confirm the image format and attach it through a compatible virtual storage controller. Match the source VM's boot and controller settings where possible. If necessary, preserve the original and convert a copy to a suitable VirtualBox format.
Deleting guest files does not reduce the host image size
Dynamic growth is generally not automatically reversed when guest files are deleted. Explain the difference between free space inside the guest and the image file's host size. Use an appropriate compaction workflow only after reviewing its prerequisites and making a backup.
Exam-relevant summary
- A virtual disk image is stored on the host but appears as a hard disk to the guest.
- Logical capacity is the maximum size presented to the guest; host storage consumption is the physical space currently used by the image.
- Dynamic allocation is thin provisioning: the image grows as data is written, up to its maximum capacity.
- Fixed allocation is thick provisioning: the full configured capacity is allocated at creation time.
- VDI is VirtualBox's native format; VMDK, VHD, and HDD support interoperability with other virtualization products.
- A disk image must be attached to a virtual storage controller before the VM can use it.
- Dynamic disks save initial host space but can grow unexpectedly and do not automatically shrink when guest files are deleted.
- Fixed disks use host space immediately and may take longer to create, but their allocation behavior is more predictable.