Deploying guest failover clusters (such as Windows Server Failover Clustering, SQL Server Always On Failover Cluster Instances, or Linux Pacemaker clusters) inside virtualised environments requires shared storage accessible by multiple virtual machines concurrently. Historically, guest clusters demanded physical SAN infrastructure, Fibre Channel adapters, or complex iSCSI target configurations. Hyper-V simplifies this requirement through Shared Virtual Hard Disks (VHD Sets using .vhds or shared .vhdx files), which support SCSI-3 Persistent Reservations across independent virtual machines. Using PowerShell in Windows 11, administrators can provision, bind, and govern shared virtual disks entirely from the command line.
Understanding Hyper-V Shared Virtual Hard Disk Architecture
In standard Hyper-V deployments, attaching a single virtual hard disk to multiple running virtual machines triggers an immediate SCSI bus conflict error to prevent filesystem corruption. Hyper-V Shared Virtual Disks overcome this by exposing native SCSI Persistent Reservations to guest operating systems:
- VHD Set (.vhds): Introduced in modern Hyper-V architectures, VHD Sets separate guest disk metadata from actual block data. This allows host-level online resizing, live backup, and snapshotting of shared cluster disks without interrupting running virtual nodes.
- Shared VHDX (.vhdx): The legacy shared disk format. While supporting SCSI-3 reservations, shared VHDX files cannot be dynamically resized or backed up at the host hypervisor layer while attached to running virtual machines.
- Storage Requirements: For multi-host Hyper-V failover environments, the shared disk must reside on an SMB 3.0 file share (Scale-Out File Server) or a Cluster Shared Volume (CSV). In local development and testing on Windows 11, shared disks can reside on standard NTFS or ReFS volumes accessible to local guest VMs.
Creating a New VHD Set (.vhds) File
To provision shared storage for a guest cluster, open PowerShell with elevated administrative privileges and generate a .vhds file using New-VHD with the -SharedVirtualDisk flag:
# Specify storage path and parameters
$SharedDiskPath = "C:\VMStorage\SharedDisks\ClusterQuorum.vhds"
# Create a 64 GB dynamically expanding VHD Set shared disk
New-VHD -Path $SharedDiskPath -SizeBytes 64GB -Dynamic -SharedVirtualDisk
For high-performance data volumes (such as SQL Server database files), provision a fixed-size shared disk to eliminate block allocation latency:
# Create a 256 GB fixed-size shared VHD Set disk
New-VHD -Path "C:\VMStorage\SharedDisks\SQLData.vhds" -SizeBytes 256GB -Fixed -SharedVirtualDisk
Attaching the Shared Virtual Disk to Virtual Machine Nodes
Shared disks must be attached to the virtual machine’s virtual SCSI controller. Standard virtual IDE controllers do not support SCSI reservations or shared multi-attach operations.
First, identify the SCSI controller numbers on the target virtual machines (e.g., Node-01 and Node-02):
# Inspect SCSI controllers on target nodes
Get-VMScsiController -VMName "Node-01"
Get-VMScsiController -VMName "Node-02"
Next, attach the shared disk to both virtual machines, ensuring the -SupportPersistentReservations switch is specified:
# Attach shared VHD Set to Node-01
Add-VMHardDiskDrive -VMName "Node-01" `
-ControllerType SCSI `
-ControllerNumber 0 `
-Path "C:\VMStorage\SharedDisks\ClusterQuorum.vhds" `
-SupportPersistentReservations
# Attach the identical shared VHD Set to Node-02
Add-VMHardDiskDrive -VMName "Node-02" `
-ControllerType SCSI `
-ControllerNumber 0 `
-Path "C:\VMStorage\SharedDisks\ClusterQuorum.vhds" `
-SupportPersistentReservations
Configuring Storage Quality of Service (QoS) on Shared Disks
Because multiple cluster nodes write to the identical virtual drive, an unconstrained node could exhaust IOPS capacity during failover testing or rebuilding operations. Enforce maximum and minimum IOPS boundaries on the shared disk attachment:
# Set minimum and maximum IOPS thresholds for Node-01
Get-VMHardDiskDrive -VMName "Node-01" | Where-Object { $_.Path -like "*.vhds" } | `
Set-VMHardDiskDrive -MinimumIOPS 200 -MaximumIOPS 5000
# Apply identical QoS policies to Node-02
Get-VMHardDiskDrive -VMName "Node-02" | Where-Object { $_.Path -like "*.vhds" } | `
Set-VMHardDiskDrive -MinimumIOPS 200 -MaximumIOPS 5000
Auditing and Validating Shared Disk Attachments
To confirm that both virtual machines recognize the drive as shared storage with persistent reservation support enabled, inspect the disk objects via PowerShell:
# Verify disk configuration across cluster nodes
Get-VMHardDiskDrive -VMName "Node-01", "Node-02" | `
Select-Object VMName, Path, SupportPersistentReservations, DiskNumber, ControllerLocation | `
Format-Table -AutoSize
Ensure that SupportPersistentReservations returns True for both instances. If the value reads False, guest clustering engines will fail to arbitrate disk ownership during node elections.
Resizing a VHD Set Online
One of the key advantages of modern VHD Sets over legacy shared VHDX files is the ability to expand disk capacity while virtual machines remain online and actively servicing cluster traffic:
# Expand the VHD Set shared disk to 512 GB while cluster is running
Resize-VHD -Path "C:\VMStorage\SharedDisks\SQLData.vhds" -SizeBytes 512GB
Once expanded at the hypervisor layer, launch Disk Management or PowerShell inside the guest operating system (e.g., Resize-Partition in Windows Server) to extend the active filesystem into the unallocated space.
Detaching and Removing Shared Disks
When decommissioning a guest cluster or reconfiguring storage tiers, disassociate the shared drive from all member nodes before deleting the underlying file:
# Detach shared drive from both nodes
Get-VMHardDiskDrive -VMName "Node-01" | Where-Object { $_.Path -like "*ClusterQuorum.vhds" } | Remove-VMHardDiskDrive
Get-VMHardDiskDrive -VMName "Node-02" | Where-Object { $_.Path -like "*ClusterQuorum.vhds" } | Remove-VMHardDiskDrive
# Safely delete the shared disk file from host storage
Remove-Item -Path "C:\VMStorage\SharedDisks\ClusterQuorum.vhds" -Force
Configuring Hyper-V Shared Virtual Hard Disks via PowerShell enables streamlined development and validation of enterprise failover clusters without investing in complex SAN hardware topologies.