Microsoft brings a new feature to Hyper-V in Windows Server 2016 called VHD Set. This type of disk enables to share virtual hard disks between several servers to implement guest cluster. In this topic we will see why using VHD Set, and how to implement it.
Why using VHD Set instead of shared VHDX
As VHD Set, Shared VHDX enables to share a virtual hard disk between multiple virtual machines. This feature is useful to implement a guest cluster where shared disks are required (as SQL Server AlwaysOn FCI or File Servers). Shared VHDX and VHD Set are great to avoid the use of virtual HBA and virtual SAN to present a LUN to the VMs. They are also necessary if you have implemented a SMB3 based storage solution. However shared VHDX feature as some limitation:
- Resizing and migrating a shared VHDX is not supported
- Make a backup or a replica of a shared VHDX is not supported
The VHD Set feature has not these limitations. However, VHD Set is available only for Windows Server 2016 guest operating system. When creating a VHD Set, two files are created:
- A .avhdx file that contains data. This file is fixed or dynamic;
- A .vhds file that contains metadata to coordinate information between guest cluster nodes. The size of this file is almost 260KB.
Create a VHD Set
To create a VHD Set, you can use the Graphical User Interface (GUI) or PowerShell cmdlets. From the GUI, open the Hyper-V Manager, select New and then Virtual Disk. As below screenshot, select VHD Set.
Then select the type of disk (fixed or dynamic), the name, the location and the size. By using PowerShell, you can run the below cmdlet:
Below you can find the result of these last two actions:
As you can see, the “blue” VHD Set is fixed and the AVHDX file size is 40GB. The “red” one is dynamic and so AVHDX file will expend its size dynamically.
Add VHD Set to virtual machines
To try VHD Set, I have created two virtual machines called VMFLS01 & VMFLS02. Each VM will be connected to two VHD Sets:
- Quorum: for the cluster Witness disk
- Shared: for the data
To mount the shared disk into the VM, edit the VM properties and navigate to a SCSI controller. Then select Shared drive.
Next, specify the location of the VHDS file.
You can also mount the VHDS in VM by using PowerShell:
Add-VMHardDiskDrive -VMName VMFLS01 -Path " c:\ClusterStorage\VMStorage01\SharedDisk\VMFLS_Quorum.vhds" -SupportPersistentReservations Add-VMHardDiskDrive -VMName VMFLS01 -Path " c:\ClusterStorage\VMStorage01\SharedDisk\VMFLS_Shared.vhds" -SupportPersistentReservations
I have repeated the same steps for the second VM. Once both VMs are connected to the VHD Set, you can start the VM.
Add-VMHardDiskDrive -VMName VMFLS02 -Path " c:\ClusterStorage\VMStorage01\SharedDisk\VMFLS_Quorum.vhds" -SupportPersistentReservations Add-VMHardDiskDrive -VMName VMFLS02 -Path " c:\ClusterStorage\VMStorage01\SharedDisk\VMFLS_Shared.vhds" -SupportPersistentReservations
Create the guest cluster
Now that both VMs are connected to the shared disk, we can create the cluster. I run the following cmdlets to install required features on each server:
# Install Failover Clustering feature and management tools install-windowsfeature -Name Failover-Clustering -IncludeManagementTools -ComputerName VMFLS01 install-windowsfeature -Name Failover-Clustering -IncludeManagementTools -ComputerName VMFLS02
Then I execute the following command to make online disks and initialize them:
get-disk |? OperationalStatus -Like "Offline" | Initialize-Disk
Now that disks are initialized, I create a partition on each disk. In the above example, the disk 1 is for Quorum usage and the disk 2 for data usage.
New-Volume -DiskNumber 1 -FileSystem NTFS -FriendlyName Quorum New-Volume -DiskNumber 2 -FileSystem NTFS -FriendlyName Data
Next I run the following cmdlets to create the cluster:
# Test the nodes to check if they are compliant to be part of a cluster Test-Cluster VMFLS01,VMFLS02 # Create the cluster New-Cluster -Name Cluster-FS01 -Node VMFLS01,VMFLS02 -StaticAddress 10.10.0.199 # I rename Cluster Disk 1 to Quorum and Cluster Disk 2 to Data (Get-ClusterResource |? Name -like "Cluster Disk 1").Name="Quorum" (Get-ClusterResource |? Name -like "Cluster Disk 2").Name="Data" # Set the Cluster Quorum to use disk Witness Set-ClusterQuorum -DiskWitness Quorum # Set the Data volume to Cluster Shared Volume Get-ClusterResource -Name Data | Add-ClusterSharedVolume
Once you have finished, you should have something like this in the cluster:
Now I’m able to copy data in the volume:
I can also move the storage to another owner node:
Thanks to VHD Set in Windows Server 2016, I can create easily Guest Cluster without using complex technologies as NPIV, virtual HBA and virtual SAN. Moreover, the resizing, the migrating and the backup is supported when implementing shared disks with VHD Set. It is a friendly feature, so why not using it?