Bobcares

Using Differencing Disks in Hyper-V for Quick VM Deployment

by | Dec 21, 2020

Need to figure out using Differencing Disks in Hyper-V for Quick VM Deployment? We can help you.

As part of our Server Management Services, we assist our customers with several Microsoft queries.

Today, let us have a detailed look into Differencing Disks in Hyper-V.

 

Differencing Disks in Hyper-V

Differential disks are to create snapshots and various VM backup systems use them. While creating a snapshot or a backup, the current VM state is saved to a VHD file.

A Hyper-V differencing disk is a virtual hard disk. We use it to store the changes made to another virtual hard disk or the guest OS.

Another interesting opportunity of differencing disks is creating some basic OS image (VHD file) with all necessary settings and software. Thus, using this image, we can quickly deploy multiple virtual machines that use the VHD of the base image and write all changes to their own virtual disks. Hence, it achieves significant savings in disk space.

The example below shows that using differential disks for 4 VMs based on a single VHD image will require only 40 GB of disk space. Whereas, with the traditional deployment model, we need 150 GB.

Using Differencing Disks in Hyper-V for Quick VM Deployment

A Hyper-V differencing disk, unlike common VHD, rigidly attaches to another parent disk.

The differential disk is a child disk and does not contain the full version of the data on the VM disk. It has only the changes the VM made during its operation.

The parent (template) VHD image stays untouched. All child virtual machines on the base of it write the changes to their own differencing disks. The size of a differencing disk is rather small.

Hyper-V differencing disks have the following properties:

  • A Hyper-V differencing disk always relates to another virtual hard disk, together they form a parent-child relationship.
  • It selects a parent disk when we create the Hyper-V differencing disk.
  • They can store any app installs, security patches, etc. allowing us to isolate changes and leave the parent disk intact.
  • Hyper-V differencing disks can be ideal for development and test purposes.
  • It can grow dynamically, meaning that the child disk grows in size only when new data is written to it.

 

Using Differencing Disks in Hyper-V for Quick VM Deployment

To use differencing disks in Hyper-V for quick VM deployment, our Support Techs suggest following these methods:

 

  • Create a Reference VHD Image

We can create a reference VHD file using the Hyper-V Manager GUI or PowerShell. PowerShell is much faster.

We should install the Hyper-V module for Windows PowerShell to use the following cmdlets:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Management-PowerShell

Create a new VHDX file:

new-vhd -path f:\vms\vhd\WinSrv2016Base.vhdx -SizeBytes 50GB –Dynamic

Create a new VM based on it:

new-vm -Name TemplateVM –Path f:\vms\vhd\ -VHDPath f:\vms\vhd\WinSrv2016Base.vhdx | `
set-vmmemory -DynamicMemoryEnabled $true -MaximumBytes 2GB -MinimumBytes 512MB -StartupBytes 1GB

Mount the ISO file with the image of the desired OS:

add-vmdvddrive -VMName TemplateVM -Path d:\WindowsServer2016DC.ISO

After we create the new VM, we need to install an OS on it. This OS must configure appropriately (install drivers, update and change the system settings).

Then generalize the OS for further deployment using Sysprep:

cd %SystemRoot%\System32\Sysprep
sysprep /generalize /oobe /shutdown

Thus, we get a reference VM image.

Now we can remove the VM itself (after saving its VHDX file). To avoid accidentally changing this VHD file, which may crash all child VMs, make it ReadOnly:

Set-ItemProperty f:\vms\vhd\WinSrv2016Base.vhdx -Name IsReadOnly -Value $true

[Stuck with reference VHD image? Contact us now!]

 

  • Create Differencing Disks and VMs on Hyper-V

Now we can create several dependents (child) VHDx files:

New-VHD -ParentPath: f:\vms\vhd\WinSrv2016Base.vhdx -Path f:\vms\vhd\Win2016-diff1.vhdx -Differencing
New-VHD -ParentPath: f:\vms\vhd\WinSrv2016Base.vhdx -Path f:\vms\vhd\Win2016-diff2.vhdx –Differencing

When we create a differencing disk using the graphic interface, select VHDX-> Differencing as a disk format. Then specify its name and the path to the parent disk.

Using Differencing Disks in Hyper-V for Quick VM Deployment

Using these VHDx files, we create two Hyper-V virtual machines:

New-VM -Name “Win2016-diff1” -Generation 2 -MemoryStartupBytes 1GB -VHDPath f:\vms\vhd\Win2016-diff1.vhdx -SwitchName “External Network”
New-VM -Name “Win2016-diff2” -Generation 2 -MemoryStartupBytes 1GB -VHDPath f:\vms\vhd\Win2016-diff2.vhdx -SwitchName “External Network”

In the end, start them:

Start-VM Win2016-diff*

[Need help with the procedure? We are available 24*7]

 

  • Merge Differencing Disks in Hyper-V

In Windows 2008 R2 Hyper-V version, it’s possible to merge differencing disks with the parent without stopping the VM.

There is a cmdlet to do it. Merge-VHD or a separate option in the Edit menu of the virtual disk in Hyper-V Manager.

Set-ItemProperty f:\vms\vhd\WinSrv2016Base.vhdx -Name IsReadOnly -Value $false
$Merge = @{
Path = ‘f:\vms\vhd\Win2016-diff2.vhdx’
DestinationPath = ‘f:\vms\vhd\Win2016.vhdx’
}
Merge-VHD @Merge

To reduce the load of the disk subsystem by multiple access to one parent VHD file, we recommend to place it on fast disks. To prevent this file from becoming the common failure point, think of the backup strategies for it.

[Can’t merge them? We’d be happy to assist]

 

Conclusion

To conclude, using Differencing Disks in Hyper-V for Quick VM Deployment provides digital storage space for securing critical data. Today we saw how our Support Techs go about with this query.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF