Virtual Hard Disk Overview
In order to make virtual machine storage portable while also delivering performance, Microsoft developed the Virtual Hard Disk (VHD) Image Format Specification which includes details of how to read and modify data contained in a VHD file. Microsoft provides the VHD file format specification to third-party developers under a royalty-free license, and many vendors, including Citrix, have adopted and use the format for their virtualization products. If you are interested in obtaining more details on the VHD file format, you can download the specification file from the Microsoft website.
Microsoft Windows Server 2008 Hyper-V uses the VHD format to encapsulate virtual machine data (operating system, application, and data files) into one or more files that are equivalent to physical drives associated with a traditional server. Therefore, if you browse the virtual machine folders on a Hyper-V server, a virtual hard disk is simply stored as a file with a .vhd extension on an attached physical disk. Virtual machines connect to a virtual hard disk through a virtualized IDE or SCSI adapter, and Hyper-V provides the mapping between the virtual hard disk and the .vhd file on the physical disk. A VHD can be stored on any IDE, SCSI, iSCSI, SAN, or NAS storage system supported by the Windows Server 2008 operating system.
You can use the Hyper-V Manager MMC or the WMI API to create new virtual hard disks. A virtual machine running on Hyper-V can support a maximum of 260 virtual hard disks through a combination of 4 IDE and 256 SCSI-connected VHDs. The bus type (IDE or SCSI) used to attach a VHD to a virtual machine imposes a size limitation on virtual hard disks. Specifically, IDE-attached VHDs cannot exceed 127 GB, while SCSI-attached VHDs cannot exceed 2 TB.
Virtual Hard Disk Types
There are two basic types of VHDs provided in Hyper-V:
Dynamically expanding disks
A fixed-size VHD is one for which data blocks are pre-allocated on a physical disk based on the maximum VHD size defined at the time of creation. For example, if you create a 100 GB fixed-size virtual hard disk, Hyper-V will allocate all 100 GB of data block storage in addition to the overhead required for the VHD disk headers and footers when it creates the new VHD.
In contrast, a dynamically expanding VHD is one for which the initial virtual hard disk contains no data blocks. Instead space is dynamically allocated as data is written to the VHD, up to the maximum size specified when the virtual hard disk was created. For example, a 10-GB dynamically expanding disk contains only VHD headers initially and requires less than 2 MB of physical storage space. As new data is written by the virtual machine to the dynamically expanding VHD, additional physical data blocks are allocated in 2-MB increments to the VHD file, up to a maximum of 10 GB.
In order to provide maximum flexibility, Hyper-V allows you to convert a fixed-size disk to a dynamically expanding disk, and vice-versa. You can also increase the size of both types of VHD files, but the VHDs must be taken offline before you can do this. In addition, Hyper-V allows you to compact a dynamically expanding disk and free up physical disk space by eliminating empty data blocks within a VHD file.
A differencing disk is a special type of dynamically expanding VHD file that is related to a “parent” virtual hard disk file as an overlay. For example, if a support engineer needs to troubleshoot operating system issues that involve different update and patch configurations, she can create a virtual machine using a fixed-size or dynamically expanding VHD (the parent VHD) and load a baseline configuration of the operating system in it. In order to create a distinct operating system configuration, she can create a new virtual machine, attach a differencing disk (the child VHD) to it that is related to the parent VHD, and modify the operating system as needed by loading new updates or patches. When the new virtual machine issues a write operation, an internal data structure in the child VHD (differencing disk) is updated to reflect changes that supersede data in the parent VHD, and the actual data is written only to the child VHD. In the case of a read operation, the same internal data structure in the child VHD is checked to determine whether to read data from the child VHD or parent VHD. Any new or changed data is read from the child VHD while unchanged data is always read from the parent VHD.
Differencing disks can be used to create very simple or very complex parent-child hierarchies. A multilevel differencing disk hierarchy is commonly referred to as a chain of differencing disks, reflecting that a child differencing disk can have a parent disk that is also a differencing disk. The chain can consist of several levels, but at the root of the hierarchy, there is always either a standard dynamically expanding or fixed-size VHD. This is important since data changes saved in a differencing disk are simply represented as modified blocks in relation to the parent disk. Therefore, a differencing disk is never used independently, but in conjunction with all disks in its hierarchy.
If you examine a Hyper-V host file system, you will see that each parent and child VHD is stored as an individual file. However, the virtual machine sees only a single disk, independent of how many levels of differencing disks are actually associated with the attached VHD.
Automatic Differencing Disks
Automatic differencing disks are similar to differencing disks. Like a differencing disk, an automatic differencing disk is used to isolate virtual machine data changes from a parent VHD. However, automatic differencing disks are used strictly to support Hyper-V virtual machine snapshots where data changes need to be quickly discarded or a rapid rollback to the base virtual machine state is required.
Unlike fixed-size, dynamically expanding, and differencing disk, which cannot be distinguished from each other by visual inspection of the filename extension (they all use .vhd), an automatic differencing disk is easily identified by a .avhd filename extension. Furthermore, automatic differencing disks are stored in a subdirectory of the virtual machine folder named Snapshots, by default.
One major distinction between differencing disks and automatic differencing disks is in the configuration process. A differencing disk is created at an individual virtual hard disk level and is usually associated with the creation of a new virtual machine. In contrast, an automatic differencing disk is created by Hyper-V when a virtual machine snapshot is taken. In addition, an automatic differencing disk is created for every virtual hard disk associated with the virtual machine. In other words, you do not have the ability to individually choose the virtual hard disks for which automatic differencing disks are generated.
Besides VHDs, Hyper-V supports pass-through disks, which allow virtual machines to access a physical disk mapped to the Hyper-V host, but that does not have a volume configured on it. Pass-through disks can be physically connected to the Hyper-V host or through a LUN on a SAN. An advantage of pass-through disks is that they are not subject to the 2 TB size limit that is imposed on virtual hard disks. In terms of limitations, pass-through disks do not support dynamically expanding virtual hard disks, differencing disks, or virtual machine snapshots. To ensure that a virtual machine has exclusive access to the physical disk, it must be configured offline on the Hyper-V host.
If you plan to use a pass-through disk to boot a virtual machine guest operating system, the virtual machine configuration file must also be stored on a different storage location. In contrast to virtual hard disks that are only files stored on physical disks, the entire pass-through disk is dedicated to the virtual machine guest operating system. Additionally, if you want to use a pass-through disk to boot a virtual machine guest operating system, it must be attached to a virtual IDE controller. In Hyper-V, the virtual SCSI controller is implemented as a synthetic device whose driver is loaded only after the virtual machine boot phase. Conversely, a pass-through disk that contains only application or data files can be connected to either a virtual IDE controller or virtual SCSI controller.
In this article, you learned that virtual machine disks can be configured as fixed-size, dynamically expanding, or differencing disks. You also learned that differencing disks and automatic differencing disks are two special types of dynamically expanding VHDs, and that automatic differencing disks are used exclusively to support virtual machine snapshots. In addition, you learned about the option to use a pass-through disk with a virtual machine, which allows you to exceed the 2 TB VHD size limit.