Creating and Configuring Hyper-V Virtual Hard Disks (VHDs)

From Virtuatopia
Revision as of 16:01, 14 January 2009 by Neil (Talk | contribs) (Creating Hyper-V Virtual Hard Disks)

Jump to: navigation, search

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:


Choosing the Hyper-V virtual hard disk type


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. Differencing disks may also be chained together. 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 accepted. Clicking Next proceeds to the Configure Disk screen shown below:


Configuring a Hyper-V Virtual Hard Disk


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.


Modifying Existing Hyper-V Virtual Hard Disks

Once a Hyper-V virtual hard disk has been created, it can be modified in a variety of ways using the Edit Virtual Hard Disk Wizard. The wizard is loaded by launching the Hyper-V Manager wizard and clicking on the Edit Hard Disks... link in the Actions panel. If the optional welcome screen appears, click Next to proceed to the Locate Virtual Hard Disk screen. On this screen, specify the full path to the virtual disk .vhd file using the Browse button to navigate to the correct file. With the correct location specified, proceed once again with the Next button which will display the Choose Action screen. The options provided depend on the type of the specified virtual disk. The following figure illustrates the options provided for a dynamic expandable disk:


Making changes to an existing dynamic expandable Hyper-V virtual hard disk


There are a total of five actions that can be performs on virtual hard disks as outlined in the following table:

Option

Description

Compact Available on dynamically expanding and differencing virtual hard disks, this option shrinks the size of the selected .vhd image file by removing unused space left behind after data is deleted from the disk. This option cannot reduce the size of non-NTFS formatted disks unless the unused space is previously filled with zeros.
Convert Converts virtual hard disks to and from fixed and dynamic expandable types.
Expand Increases the size of dynamic expandable and fixed virtual hard disks.
Merge Merges the contents of the selected differencing virtual hard disk into the corresponding parent virtual hard disk. Alternatively, the contents of both the parent and child virtual hard disks may be merged into a new virtual hard disk, thereby leaving the original parent disk image unchanged.
Reconnect Differencing disks must be associated with a parent virtual hard disk. This option allows a differencing virtual hard disk to be reconnected with a parent disk.

Getting Information about a Hyper-V Virtual Hard Disk

Removing a Virtual Hard Disk from a Hyper-V Virtual Machine

Moving Hyper-V Virtual Hard Disks between IDE and SCSI Disk Controllers