Creating Hyper-V 3 Differencing Disks in Server 2012 with GUI and PowerShell
I’m not sure how this feature passed me by up until now. Differencing Disks are like VMware Linked Clones, you have Parent VHD and a number of linked VHD\VHDX for VMs that only record the changes from the Parent. A full Server 2008 R2 VHDX is around 11GB, a sysprep’d Differencing disk is around 1GB, meaning more machines in less space, ideal for Test and Dev. I’ve now got a SSD in my lab Server (which makes a huge difference in performance when running multiple VMs). I was looking into Server 2010 dedupe, but found that is only for VHDs at rest, i.e. libraries of VHD images, not live in use disks. With differencing disks I can make much better use of my SSD.
So how do you create a VM with differencing disks? First you start with a Master or Parent disk. I have a sysprep’d Server 2008 R2 VHDX. Mark it as read only so you don’t inadvertently change it. If you do all the child disk will be unusable.
The Easy way to do this is PowerShell:
# Create the VM (with no VHD at this stage)
New-VM –Name lab50-PSDiffDiskVM –MemoryStartupBytes 1024MB -SwitchName “INTERNAL LAN” -Path T:\lab50\lab50-PSDiffDiskVM -Verbose
# Create our New Differencing Disk
New-VHD –ParentPath T:\02R2June2012\08R2TemplateJune2012.vhdx –Path T:\lab50\lab50-PSDiffDiskVM\lab50-PSDiffDiskVM.vhdx -Differencing
# Attach this Disk to the VM
Add-VMHardDiskDrive lab50-PSDiffDiskVM -Path T:\lab50\lab50-PSDiffDiskVM\lab50-PSDiffDiskVM.vhdx
# Start VM
Want to go the GUI route?
You can’t create a differencing disk during the standard new VM wizard
You can either create the disk first;
Or create the VM, then go into the New disk option;
Either way you end up at this wizard
You then attach this disk to your VM
The disk starts at 4MB. After the machine is sysprep’d and hostname changed, the disk goes up to around 1GB (compared to 11GB for the full image)
How do you know a VM is using a differencing disk? It’s in the properties
And here is the PowerShell way:
Get-VMHardDiskDrive <VMNAME> | Select-Object Path | Get-VHD