Creating and Configuring Hyper-V Virtual Hard Disks (VHDs)
In Creating Hyper-V Virtual Machines we looked at creating a Hyper-V Virtual Hard Disk (VHD) as part of the Create New Virtual Machine wizard process. Unfortunately, the ease of use of the wizard masks some powerful features of Virtual Hard Disks within Hyper-V. The purpose of this chapter, therefore, is to cover some of the more advanced features of Hyper-V virtual hard disk creation and configuration.
Creating Hyper-V Virtual Hard Disks
As previously covered, virtual hard disks can be created as part of the virtual machine creation process. To gain access to a wider range of disk configuration options, an alternative is to create the disk independently of the virtual machine, and then subsequently assign to the virtual machine after the disk has been created.
New disks are created from the Hyper-V Manager (Start->Administrative Tools->Hyper-V Manager). Once Hyper-V Manager is running, select the desired Hyper-V host from the left hand panel and then click on the New->Hard Disk... option in the Actions panel. This will invoke the New Virtual Hard Disk wizard. If the welcome screen appears, click next to proceed to the Choose Disk Type screen as illustrated in the following figure:
Hyper-V supports three different types of virtual hard disk:
- Dynamically Expanding - Dynamically expanding virtual hard disks start small and then automatically expand to provide more capacity on an as needed basis. Note that the dynamic feature only applies to expansion. In other words, the virtual hard disk will not automatically decrease in size when data is removed.
- Fixed - Fixed virtual hard disks are created at the size specified during the disk creation process. The size of fixed virtual hard disks can be altered using the Hyper-V Manager Edit Disk... action to launch the Edit Virtual Hard Disk Wizard.
- Differencing - Differencing is a concept which involves a parent disk and a child disk. The parent disk contains a baseline hard disk image with the operating system and perhaps a range of applications and data installed. Once this baseline parent disk is configured, a differencing disk is assigned as a child. When the virtual machine to which the disk is assigned runs, any changes made the baseline parent image are actually stored on the child differencing disk, leaving the parent disk unaltered. Multiple child disks may be assigned to a parent disk allowing multiple virtual machines to share the same parent disk. The changes contained in a differencing disk may be merged into the parent disk. Alternatively, a new virtual hard disk may be created containing the merger of the parent disk and the child disk, thereby leaving the parent disk unaltered. When creating a differencing disk, the parent disk will need to be specified. The size of the differencing disk increases as space is required. Differencing disks may also be compacted to free up unused space (see the section below entitled Modifying Virtual Hard Disks).
Once a disk type has been selected, click Next to specify a name and location for the virtual disk. Any location accessible to the host system may be used, or the default location used. Clicking Next proceeds to the Configure Disk screen shown below:
After selecting the initial size of the disk, the option is then provided to clone the image of a physical disk into the new virtual hard disk, allowing an existing operating system configuration to be duplicated on the virtual hard disk. A list of physical hard disk drives detected on the host system is provided for selection.
After clicking Next the summary screen is displayed. Clicking Finish initiates the disk creation process.