What’s The Difference? Creating Parent and Differencing VHDs Through Hyper-Visor

Image credit: Carl Boisson

The VHD Age

When Microsoft created the .VHD format, they streamlined the process of managing storage in environments that have become increasingly virtualized. Virtual Hard Disks (VHD) are logical representations of storage that can be manipulated in a similar fashion to real disks. Blank VHDs can be created for use as storage spaces for Virtual Machines (VMs), or they can be preloaded with Operating Systems (OS) and used to run those VMs themselves. VHDs are also highly portable as admins can easily transfer them over their networks without having to physically remove disk drives.

While VHDs allow for greater flexibility in storage management, their ease of creation can accelerate capacity loss. For example, within minutes an administrator can create 8 VHDs preloaded with Windows Server 2012. If each VHD is 8GB, that would be a total of 64GB! In the real world, this example is repeated many times over. This can greatly increase storage costs as additional hardware would be required to meet capacity needs.

Increased portability also comes at a cost. VHDs, specifically dynamically expanding ones, can easily swell in size, especially if they’re loaded with an OS. Transferring these large files over a network can increase traffic and drain bandwidth. Microsoft has found a novel way to dress both of these concerns without affecting VHD functionality.

A Vast Difference

Sysadmins can now use differencing disks to minimize the footprint of VHDs on drives and conserve bandwidth. These are special VHDs that share a special Parent/Child relationship with regular VHDs. A Parent VHD contains all the raw data (OS, software, files) that an admin wants to be “reproduced” in the differencing disk(s). The differencing disks “pull” the shared data from the parent, and the only data written to the “child” VHD file are changes that differ from the parent (hence, the name).

Because the resulting VHD file only contains differencing data, the result is a file that’s a fraction of the size of the parent disk. Take our 8 VHDs from our prior example, then totaling to 64GB. Now they would come in at little over 1MB if they were created as differencing disks with the same Parent.

Often, network administrators are moving VHDs across intranets and the internet. Differencing disks are smaller files which are easier to transfer over networks. This reduces transfer times and costs associated with mitigating bandwidth blockages.

Do It Like Disk

1 . Organization*

In order to keep track of your VHDs, it is best practice to make your folder (directory) hierarchies and names consistent with the purpose of each disk. For example, adding “parent” or “base” to the file name of the parent VHD. I also recommend separating the parent VHD from the differencing disk.

Parent and differencing disks should have their own folder
The names of the files should reflect their purpose

**Note: If data on a parent disk is altered in any way, it will be reflected in all the differencing disks created from that parent. This is akin to changing their DNA as all “child” disks share the same core data (see intro image). This may result in having to run sysprep many, many, many times.**

2. Preparing the Parent Disk

Sysprep is a command line tool which reverts a running operating system to an out-of-box state by generalizing uniquely identifying data. This includes user accounts and Security ID numbers (a SID can be likened to a social security number for computers). Depending on the source of the VHD you intend to use as the parent, this step may not be necessary. For example, if you downloaded a Server 2012 VHD directly from Microsoft, you can move on to the next step. However, if you’re unsure and you skip this step, you may end up having to run sysprep many, many, many times. If performed successfully, a VM created with a differencing disk from this parent will start with an out-of-box experience. This ensures that identifying attributes, such as SIDs, will not be duplicated.

Create a new VM and use the desired parent VHD as its disk, run it and then:

  • Run Command Prompt
  • Type: cd C:\Windows\system32\sysprep
    (where “C:” is your OS directory)
    Press Enter
  • Type: sysprep
    Press Enter
    (this will start sysprep.exe)
  • Select Enter System Out-of-Box Experience (OOBE)”
  • Check Generalize
  • Select Shutdown
  • Click OK
Make sure “Generalize” is checked
It may take a while
  • Ensure the VM is shut down.
VM in the OFF state

3. Create the Differencing Disk

Using Hyper-V (the same program used to create and manage VMs):

  • Click New > Select Hard Disk…
  • Select VHD” > Click Next
    (the format must match the parent)

Select Differencing” > Click Next

  • Type the desired name* of the differencing disk
  • Browse to the desired directory* > Click Next
Remember, stay organized
  • Browse to the Parent VHD > Click Next
  • Click Next > Click Finish (repeat for each disk)
A set of 8 differencing disks from 1 parent. Note the small file sizes.

4. Verification

You can test drive your new differencing disks by creating VMs with them as the disk. You can also use Hyper-V to inspect the disks and verify the path to the parent.

  • Click Inspect
  • Browse to differencing disk
Disk properties point to parent disks

What A Difference A Disk Makes!

Now you’re well on your way to impressing your employers by setting up differencing disks to save time (bandwidth) and money (storage costs). If you’d like some learn more about differencing disks or VHDs in general, check out the links below. Thanks for reading!

Additional Resources:
Using differencing disks | Virtual Storage Explained | Storage Pools Guide

Key Terms:
Bandwidth
Differencing disk
Dynamic disk
Logical disk
Internet
Intranet
Network traffic
Operating system
SID
Storage spaces
Sysprep
Virtualization
Windows Server 2012

Thanks to our super-editor extraordinaire Saron Yitabarek ; dishing out smiles and commas!