Testing and Experimentaition: Differential VM's

 
hypervnesting.png
 
 

Im toying around with creating Differential VM’s for a project in the future, So I will be documenting the creation of a differential vm in Hyper-V now and probably in Unraid’s KVM later. The OS im doing this with is Windows 10, I am going to assume you know how to create a VM in Hyper-V. 

Now for the method below is how to create multiple different machines from one initial image, If you wanted to create a differential VM to test something like installing a program on your VM so no changes are made to your initial VM skip Step one

Step one: Creating your initial image

Ok as part of creating your initial image you will need to install windows on your VM and then the software you want on all of the subsequent images. Once you have done this goto and trigger the below program.

C:\Windows\System32\Sysprep\sysprep.exe

Select Generalize, Out of the box experience (OOBE) and then shutdown.

Now you need to make it so the OOBE does not trigger when we boot the new machines. First you will need to create a folder on your c: called mount. Then enter the below command

DISM /Mount-Image /ImageFile:”PathToVHD”  /MountDir:c:\mount /index:1

Then download the file below, This is what i created using Windows Configuration Designer if you don't feel safe using this on your installation you can download that and create your own. You can also customize the installation in more ways should you wish.

OOBEdisable.ppkg

When you have downloaded the patch or created your own execute the below command

DISM /Image=C:\Mount /Add-ProvisioningPackage /PackagePath:”PathTo”DisableOOBE.ppkg

Once this completes.

DISM /Unmount-Image /MountDir:C:\Mount /commit

Step 2: Creating a Differential VHD

Now your VHD is ready to be used as the root of a differential VM. Use the below command to create your differencing VHD, As a note put both your base and Differencing in a new location if you leave it in the same location as the base vm you won't be able to read from it with your new VM.

New-VHD -ParentPath: “PathToBaseVHD.vhd(x)”  -Path “PathToNewVHD”.vhdx -Differencing

Now all you need to create a new VM using the new VHDX and only the changes will be written to the new HDD file. This will save space as you wont need to store repeated OS installs but it does have its downfalls.

The Experiment

Now after i got all that done what i wanted to see was that if i updated the base image would that apply to all the VM’s. Quick answer is no! Once you change the base vhd in any way the differential VHD will encounter an error.

Now while i can see uses for differential VHD’s, Saving space for thin clients. However the fact that you will still duplicate updates will still be an issue and use up space on the VM’s. The only way I can see around this would be to update the base VHD at regular interval then destroy and re-create the subsequent VM’s. If you had an environment where nothing is stored locally (Roaming Profiles, Home Drives), You can also make the process easier if you use Windows Configuration Designer to auto enroll the imaged VHD into the domain.