Introduction
VDI is the native virtual disk format of
VirtualBox. When VirtualBox creates a new
virtual machine it makes a .vdi file to act as its hard disk, unless another
format is chosen.
A VDI can be fixed, with the whole disk allocated at once, or dynamic, growing as the guest writes data. Snapshots are stored as further VDI files that record only the changes from their parent.
Structure
The file starts with a line of text naming the program, such as
<<< Oracle VM VirtualBox Disk Image >>>, padded to 64
bytes. Older files name innotek or Sun instead. At offset 64 comes the signature
0xBEDA107F, stored little-endian, then the version and the rest of the
header: the image type (dynamic, fixed,
undo or differencing), a description, the offsets of the block map and of the data,
the disk geometry, the disk size, the block size, which is 1 MB by default, the number
of blocks and of allocated blocks, and the IDs of the image, of its last modification
and of its parent.
The block map has one 4-byte entry per block of the virtual disk, giving the block’s position in the data area, or a special value for a block that has never been written. The data area holds the allocated blocks in the order they were first written.
0Text banner the program’s name, padded64 bytes64Header signature0xBEDA107F, version, type, offsets, sizes, IDsvaries…Block map one entry per block of the disk4 bytes per block…Data blocks the written parts of the diskrepeated
Not described
The viewer reads the pre-header, the header of version 0 and of version 1.1 (384 and 400 bytes), the block map, and normal,
fixed, undo and differencing images. It opens the disk’s contents as a file, so the partition table and file systems inside can
be read; a disk of terabytes opens without reading its size, because only the block map is read. Every detail of the viewer
comes from one file, VirtualBox’s VDICore.h (GPL-3.0, from the public source tree), except where the next bullets
say otherwise. It was built and tested with images made from that header; qemu-img was not available, so the contents
were compared with the raw disk each test image was made from, and no image written by VirtualBox itself was tested.
Known, not yet covered
- Viewer: a differencing image’s parent is not opened (it is another file): the blocks that belong to the parent (free in the block map) read as zeros and the Block map table says which they are. The linkage and parent modification UUIDs are shown, so the parent can be found by hand; this limit comes from a viewer that is given one file at a time.
- Viewer: the image flags are shown as a number, not by name: their values are defined in VirtualBox’s
vd.h, which was not read. - Viewer: two details are not in
VDICore.hand are taken from the field comments and the macro names there: that a block’s data lies after itscbBlockExtrabytes atoffData+ index × (cbBlock+cbBlockExtra), and that the version word is major in the high 16 bits and minor in the low 16 (the macrosVDI_GET_VERSION_MAJORand_MINORare defined elsewhere). The file says nothing about byte order; the viewer reads little-endian numbers, which is what VirtualBox writes on its hosts.
Unknown
- Reference: VirtualBox publishes no specification; the pages follow its source code. The header read does not define the individual image flag bits or the byte order of its UUIDs (header).
Links
Software
- VirtualBox and VBoxManage – Oracle’s free virtual machine software and its command-line tool, which create and run VDI disks (Windows, macOS, Linux)
- QEMU and qemu-img – run and convert VDI files (Windows, macOS, Linux)
- 7-Zip – free archiver that opens VDI files like an archive (Windows)
Developers
- libguestfs – library and tools for reading and changing the files inside disk images (C)