June 3, 2019
How To Use Hyper-V Differencing Disks: A Complete Guide
Virtual hard disks are rightfully considered an essential part of a Hyper-V environment as they provide digital storage space for securing critical data. Hyper-V virtual hard disks can be of three types: fixed, dynamically expanding, and differencing. In this blog post, we are going to focus on how Hyper-V differencing disks work and how they can be used for virtual machine (VM) deployment.
In a nutshell, this blog post attempts to answer the following questions:
What is a Hyper-V differencing disk? – A Hyper-V differencing disk is a virtual hard disk used for storing the changes made to another virtual hard disk or the guest operating system (OS).
What can Hyper-V differencing disks do? – Hyper-V differencing disks have the following properties:
- A Hyper-V differencing disk is always related to another virtual hard disk, together with which they form a parent-child relationship.
- A parent disk is selected when you create the Hyper-V differencing disk.
- Hyper-V differencing disks can store any app installs, software updates, security patches and so on, which allows you to isolate changes and leave the parent disk intact.
- Hyper-V differencing disks can be ideal for development and testing purposes, as they can help your reverse implemented changes.
- Hyper-V differencing disks can grow dynamically, meaning that the child disk grows in size only when new data is being written to it.
Read further to learn how you can use Hyper-V differencing disks to improve VM deployment as well as how NAKIVO Backup & Replication can help you protect the entire virtual infrastructure with a single product.
What Is a Hyper-V Differencing Disk?
A Hyper-V differencing disk is a type of disk which can be used for storing the changes taking place in the parent virtual hard disk. When you create a differencing disk, you must specify which virtual hard disk can be used as the parent for that new differencing disk. As a result, these disks can form a parent-child relationship, where the virtual hard disk is referred to as the ‘parent’ disk and the differencing disk is called the ‘child’ disk. All changes to the data or operating system (OS) are written to the child disk, whereas the parent disk is left intact.
How Hyper-V differencing disks work
Each differencing disk can have only one parent disk whereas a single parent disk can be associated with multiple differencing disks. This way, you can build a highly functional virtual environment, where each VM can have its own differencing disk for storing various configurations which differ from the parent disk.
You can organize Hyper-V differing disks in a chain, which implies that a differencing disk can have another differencing disk as the parent. If arranged properly, a disk chain allows you to reduce storage space requirements considerably. Building a chain of differencing disks can be especially helpful when you want to test OS updates but also have the ability to reverse changes in case of failure. However, it is critical that you ensure that all disks in a disk chain, except for the newest child disk, are locked. If any changes are applied to one of the older disks in the chain, this might result in chain failure and data loss. Only the latest child disk should remain unlocked and be ready to store the recent changes to the VM.
Another interesting point is that Hyper-V differencing disks can grow dynamically, meaning that they only expands in size when the new data is being added to them. Potentially, a differencing disk can grow as large as the maximum size assigned to the parent disk.
If you want to identify which parent disk a particular differencing disk is associated with, you can use the Inspect Disk action in Hyper-V Manager. For this purpose, simply open Hyper-V Manager, click Inspect Disk and select the differencing disk that you want to inspect. After that, you will see the virtual hard disk properties on your screen. By clicking Inspect Parent, you can determine the existing parent-child relationship.
You can use the information about the parent-child relationship in case you want to merge the data stored in differencing disks. Note that Hyper-V differencing disks can be merged to either the parent disk or a new virtual disk. Should you decide to merge the changes stored in a differencing disk to the parent disk, the child disk is destroyed after the merging operation is complete. If you decide to merge changes to a new virtual disk, both the parent and the child disk will remain in the current state, and a new disk will combine the data of both disks.
Using Differencing Disks for Hyper-V VM Deployment
Below, I am going to explain how you can use Hyper-V differencing disks to make the process of creating VMs quickly and easil. The entire process includes the following steps:
- Create the parent disk
- Create Hyper-V differencing disks
- Create a VM using a Hyper-V differencing disk
This approach can be used in lab environments or VDI environments where you need to create multiple VMs with similar configurations in a short span of time. Let’s see how this can be done.
How to create a parent disk
Due to the fact that a differencing disk is always associated with another disk, the parent disk must be created beforehand. Note that a parent disk can be any of the three types (fixed, dynamically expanding, or differencing), but the parent disk and the child disk must have the same VHD format (VHD or VHDX). Let’s start with creating a new VM using Hyper-V Manager.
1. Open Hyper-V Manager.
2. In the Actions pane, click New and select Virtual Machine. The New Virtual Machine Wizard will open, where you can create a new VM following the prompts.
3. Read the Before You Begin section and check the box Do not show this page again below if you want to skip this information in the future.
4. In the next section, you should choose the name and location of your new VM.
5. The following step is to choose the generation of the new VM.
6. In the Assign Memory section, you can specify the amount of startup memory which can be allocated to the new VM.
7. In the next section, you can select a virtual switch which will be used for networking.
8. In the Connect Virtual Hard Disk section, you can specify which virtual hard disk to attach to a new VM.
9. In this section, you can choose how your OS should be installed. Click Create a virtual hard disk to create a new parent disk.
10. In the Summary section, you can see properties of the new VM which you want to create. Click Finish to create the VM and close the wizard.
After the operation is complete, you can access a new VM using Hyper-V Manager. Right-click the VM’s name and select Start. Double-click the VM’s name to open the Virtual Machine Connection window and install an OS on the newly created VM. After the installation operation is complete, you should generalize the OS for further deployment using Sysprep. Running Sysrep allows you to remove all of the security and identification information from the computer. As a result, you can reuse this clean Windows image on different computers and seriously cut down on VM deployment time.
To generalize the OS, you should do the following:
- Start the VM.
- Open the Command Prompt.
- Run %WINDIR%\system32\sysprep\sysprep.exe to launch the Sysprep tool.
- Check the Generalize box.
- In the Shutdown Options, select Shutdown instead of Restart. This way, you will have time to copy the Windows image before the VM is started. Click OK.
After that, we should set the parent disk to be read-only so as to stop any changes being written to it. To this end, find the parent VHD on your computer, right-click on its name, select Properties, and check the box below Read-only. Click OK to implement changes.
How to create Hyper-V differencing disks
After creating the parent disk, you can finally start creating Hyper-V differencing disks. To create a Hyper-V differencing disk in Hyper-V Manager, you should do the following:
1. Open Hyper-V Manager. In the Actions section, select New and click Hard Disk. The New Virtual Hard Disk Wizard should open.
2. Look through the Before you Begin section.
3. In the Choose Disk Format section, select VHDX. Remember that the parent disk and its child disks should be of the same VHD format.
4. Choose Disk Type section, click Differencing.
5. In the Specify Name and Location section, type the name of the new VHD file and set its location.
6. In the Configure Disk section, specify which virtual disk can be used as the parent for the new differencing disk.
7. In the Summary section, check the properties of the new virtual hard disk which you want to create. Click Finish.
After the operation is complete, you can verify that the Hyper-V differencing disk has been created by opening the folder where it is expected to be stored.
How to create a VM with a Hyper-V differencing disk
Now you can use the Hyper-V differencing disk we have just created for VM deployment. Let’s start with opening Hyper-V Manager and launching the New Virtual Machine Wizard. You have to go through the same process of configuring a new Hyper-V VM and assigning the same VM properties as we did earlier. However, in the Connect Virtual Hard Disk section, you need to choose Use an existing virtual hard disk.
Look through the Summary section to verify that everything is correct and click Finish to create the VM and close the wizard.
Using previously created Hyper-V differencing disks, you can create multiple VMs which will have a preconfigured OS running on them. As a result, you can simplify the process of managing Hyper-V VMs in addition to reducing the storage requirements for VM deployments. Creating Hyper-V differencing disks is a good option when working in test environments as this allows you to isolate changes and easily reverse them if there is a need.
In this blog, we talked about Hyper-V differencing disks and how they can improve VM deployment. However, you should be careful when working with Hyper-V differencing disks because there is a high risk of losing all critical data if disks are not properly managed. For example, if you do not write-protect the parent disk, new changes can be applied to it. As a result, all Hyper-V differencing disks associated with this parent disk will become invalid and all essential data will be lost. To avoid such issues in future, it is recommended that you install a data protection solution which can securely back up all your VMs and applications as well as instantly recover everything you need in just a few clicks.
NAKIVO Backup & Replication is one of the most reliable and powerful Hyper-V backup solutions, which can also help you protect VMware, Nutanix, AWS EC2 environments and Microsoft 365, while saving time, effort, and money.