One of the Hyper-V features that seems to be the source of a lot of confusion for Windows administrators is the differencing disk feature. A Hyper-V differencing disk is unique because it maintains a parent-child relationship with another virtual hard disk. In this article, I want to shed some light on how this feature can be useful and review best practices for using differencing disks.
To show you how they might be useful, consider a situation in which you need to set up a dozen different virtual machines (VMs) for a lab environment. Normally in a situation like this, you will need to manually provision each VM, unless you configure System Center for automatic VM deployment. Needless to say, it would be really time-consuming to manually create a dozen VMs from scratch. In this type of situation, differencing disks are a time-saving shortcut.
For the sake of this discussion, let's assume that each VM will run the same operating system, and only the applications will vary from one VM to another. Because all VMs will run a common operating system, there is a high degree of similarity from one VM to the next. We can take advantage of that similarity to save time.
To do so, we would create the first VM in the usual manner, which means installing the Windows operating system, applying any necessary patches and performing any other configurations that all the VMs will share. After we create the first VM, we shut it down, move the virtual hard disk file somewhere safe and then delete the VM. Now, we create each of the VMs that we are going to need for our lab, but we do so using differencing disks that link back to the virtual hard disk we created in the previous step. That way, each VM will have a preconfigured operating system. In essence, all of the VMs are sharing the same parent virtual hard disk.
Of course, this raises the question about differences between VMs. Every VM will need a unique computer name and IP address. Additionally, there are certain operating-system-level identifiers that must be unique for every computer on the network. So how does this method account for these requirements?
When we use differencing disks, all of the VM-level write operations are directed to the differencing disk. The parent virtual hard disk remains in the original state and its contents are never modified. That being the case, we can change the computer name, join the computer to a domain or assign a unique IP address to the individual VMs without ever having to worry about making changes that will impact the remaining VMs.
Now that I have talked about how differencing disks might be useful, let's consider some best practices for using them. The first best practice I recommend is that you avoid using them in situations where performance is critical. The parent-child relationship between a virtual hard disk and a differencing disk has a bit of an effect on read performance. This affect is not sufficient to warrant never using differencing disks in production environments, but you don't want to use them in any situation in which you need top-notch performance.
You should also put some serious thought into creating the parent virtual hard disk. The parent virtual hard disk and the differencing disks must be in the same format. In other words, if the parent virtual hard disk is in VHDX format, then the differencing disks must also be VHDX based. The initial format you choose will directly affect the types of differencing disks that you can create.
I also recommend that when you create the parent virtual hard disk, you create a fixed length disk. Remember, the parent disk is essentially going to be a read-only disk. So, there is no advantage to creating a thinly provisioned, dynamically expanding virtual hard disk. Furthermore, fixed length virtual hard disks deliver better performance than dynamically expanding virtual hard disks. So, using a fixed virtual hard disk can help you to overcome some of the performance reduction associated with using differencing disks.
One last best practice is to place your parent disk on the highest performance storage that you have available. Remember, multiple VMs will be simultaneously reading from your parent disk. If the underlying physical storage is unable to keep pace with all of the read requests, then you will see a performance bottleneck for every VM that has a relationship to the parent disk. The only way to prevent this type of storage bottleneck is to use high-performance storage.
Differencing disks are very useful in lab environments, VDI environments, and in situations where there is a high degree of consistency between VMs, but top-tier performance is not a requirement. When using differencing disks, it is important to adhere to various best practices in order to ensure that your VMs do not suffer from performance bottlenecks.