This video looks at the virtual hard disk format (VHD and VHDX) used by Windows. What it can achieve and what you need in order to use it.
Virtual Hard Disk (VHD)A virtual hard disk is essentially the data that would normally be stored on a physical drive stored in a file. When a virtual machine is created, virtual devices are created. For example, virtual devices may be created for the CPU, memory and hard disk. The virtual hard disk is connected to the VHD file and thus any data that is written to the virtual hard disk will be written to the virtual hard disk file. Since a virtual hard disk is being used by the virtual machine, this means that the virtual machine can have additional features added that are not possible when using a physical drive. For example, if you wanted to save the state of the virtual hard disk, this could be stored and restored later on. This is referred to in virtual machines as a checkpoint or a snapshot.
Virtual Hard Disks Explained
When you install an operating system in a virtual machine, the operating system sees virtual hardware. Like physical hardware, the operating system needs device drivers in order to access this virtual hardware. The operating system will communicate with the device driver just like it would to access physical hardware. Once the device driver communicates with the virtual hardware, the virtual solution is able to add additional features. For example, it is able add snapshots and dynamic disks. Dynamic disks is a feature that allows the virtual file to grow in size as data is added to it.
Virtual Hard Disk (VHD)
The virtual hard disk format was first obtained by Microsoft in 2003 when Microsoft purchased the company that developed it. It was used in Microsoft Virtual PC and then was continued to be used in other products like Hyper-V. Virtual hard disks support a number of different formats to store the data in. These includes, fixed, dynamic and differencing.
Fixed
The fixed file format used for virtual hard disks uses a virtual file that is the same size as the physical drive. Since the file is the same size, this offers excellent performance. This is because not much processing is needed in order to determine when the virtual hard disk needs to be accessed. The disadvantage with this is that fixed-size VHD files are slower to create than other virtual hard disk types. This is because in order to create the virtual hard disk file, a file needs to be created that is the same size as the physical hard disk.
Dynamic
Dynamic virtual disks use space only as required. When the dynamic disk is first created, this is a fast process as only the basic data structures are created in the file. As data is added to the dynamic disk, the dynamic disk increases in size. For example, if you store 20 gigabytes of data on a virtual hard disk, the virtual hard disk will be about 20 gigabytes in size. The cost of this is that there is reduced performance of the virtual hard disk. If you add and remove a lot of data, the virtual hard disk becomes fragmented. This reduces the performance of the virtual disk and also increases it size. In order for the virtual hard disk to work as well as it can, the administrator can choose to compact the virtual disk. This rearranges that data on the virtual disk as well as frees up any unused space in the virtual disk and reduces the size of the virtual disk. It is recommended that the virtual hard disk be compacted when the operating system is first installed or if the virtual hard disk is being archived. For example, the virtual hard disk is been saved to removable media like optical media.
Differencing
A differencing virtual disk is when two virtual hard disks are used. One is the parent and the other is the child. A virtual machine that is using a differencing disk will see a virtual hard disk that contains the parent and child data combined together. The parent virtual hard disk contains the initial data and the child contains any changes to the virtual hard disk. The advantage of differencing is that the same parent virtual disk can be used with many virtual machines. This can save the administrator a lot of space when there are multiple virtual disks that are using the same data. It is recommend that once the parent virtual disk has been created, the virtual disk file containing the parent disk is made read only. This is because any changes that are made to the parent disk will be seen on all virtual machines that are using that parent disk.
Virtual Hard Disk (VHD)
The advantage of using virtual hard disks is that they are easy to move, backup and restore. If you need to duplicate the virtual hard disk file, it is a simple matter to create a copy of the virtual hard disk file. The original VHD file format has a limit of 2 Terabytes in size and the use of a virtual hard disk file adds some overhead. To overcome some of these limitations the VHDX file was created.
VHDX Virtual Disk Format
The newer virtual hard disk format called VHDX overcomes some of the limitations of the VHD format. It supports 64Terrabyte size virtual hard disks, an increase from 2040 Gigabytes on VHD files. The virtual hard disk format also uses transactions when updating the data on the virtual hard disk. For this reason, the virtual hard disk is less prone to data corruption due to power loss. Performance is also improved as the VHDX format is able to align the virtual hard disk with large sectored disks. Support is also added for Trim. Trim is used in solid state drives so that the data is written evenly across the solid state drive to minimize ware on the solid state drive, increasing its lifespan. The disadvantage of VHDX files is that you require Windows Server 2012 or Windows 8 or above in order to use them. It is possible to convert between the two formats as long as when converting to the VHD format, the virtual hard disk is less than 2040 gigabytes.
References
“VHD (file format)” http://en.wikipedia.org/wiki/VHD_(file_format)
“Compacting dynamically expanding virtual hard disks” http://technet.microsoft.com/en-us/library/cc708394(v=ws.10).aspx
“Hyper-V Virtual Hard Disk Format Overview” http://technet.microsoft.com/en-us/library/hh831446.aspx
Credits