In this blog post, I’m going to talk about a new feature Microsoft has brought to Hyper-V in Windows Server 2016 called VHD (Virtual Hard Disk) Sets and how to configure them.
What is a VHD Set?
A VHD Set is a type of disk that enables you to share Virtual Hard Disks between at least two virtual servers so you can implement a guest cluster such as SQL Server AlwaysOn, file server, or even a Hyper-V failover cluster for lab purposes.
With this new technology, you are finally able to perform an online resizing of the shared virtual disks, utilize Hyper-V native replication mechanism to duplicate your data, and include VHD sets in the application-consistent checkpoints. In Windows Server 2016, these are called production checkpoints.
VHD Sets have their own extension now which is .VHDS. VHD Sets use metadata to store information about checkpoints and all aspects of managing the checkpoint chain and merging shared VHD Sets. All of this is handled by Hyper-V.
VHD Sets have the same prerequisites as the older technology, Shared VHDs. The main pre-requisite is the .VHDS file that you want to share needs to be placed on either an SMB 3.0 share or a Cluster Shared Volume (CSV).
Using Hyper-V Manager to create a VHD Set
In Hyper-V Manager, click New in the Action Pane.
Click on Hard Disk…
Select VHD Set and click Next
Choose what type of disk you would like. For this demo, I’m just going to use Dynamically expanding.
Enter a Name for the new .VHDS and a Location that you would like it saved to. Then click Next.
Enter a Size for the new .VHDS in GB. Then click Next.
Make sure everything is ok and click Finish
Using PowerShell to create a VHD Set
To create a new VHD Set in PowerShell, we use the New-VHD cmdlet and specify the new file type .VHDS for the -path parameter.
Open PowerShell with elevated permissions and type:
New-VHD -Path "V:\Hyper-V\guestcluster01\Virtual Hard disks\shared02.vhds" -SizeBytes 100GB -dynamic
What this command does is create a .VHDS file in the –Path you specify, -SizeBytes sets the size of the .VHDS file, and –Dynamic sets the disk type. -Dynamic can be changed to –Fixed if you want to use a fixed disk type.
Adding a VHD Set to virtual machines
Now that we have created our virtual machine set, we have to add it to a virtual machine. In this section, I will show you how.
Using Hyper-V Manager to add a VHD Set to a virtual machine
In Hyper-V Manager, right-click the VM you want to add the .VHDS to and click Settings.
Navigate to SCSI Controller. Make sure Shared Drive is selected and click Add
Locate your .VHDS file and click Open
Repeat the above steps on the other VM you would like to share this new .VHDS with.
Using PowerShell to add VHD Sets to virtual machines
Add-VMHardDiskDrive -VMName PIXEL-VHM02 -path "V:\Hyper-V\guestcluster01\Virtual Hard Disks\shared01.vhds" -SupportPersistentReservations
To add the .VHDS to another virtual machine, all you have to do is to change the –VMName.
If you get an error message like the one below, then you need to make sure that the .VHDS is stored on a CSV or a clustered file share.
If you want to test VHD Sets in your home lab/demo lab and only have one node and no CSVs, you can use the following command in an elevated PowerShell window to allow the usage of your current storage.
fltmc.exe attach svhdxflt V:
Just make sure you change the drive letter from V: to the one you have the shared VHD on.
And that’s it. Microsoft has made this new feature very easy to use which has now made it easier for us sysadmins to easily create guest clusters without using complex technologies such as NPIV, virtual HBA, and virtual SANs.
Thank you for reading this post and I hope you found it useful. If you have any questions, please leave a comment.