Delen via


How to hot-add a Shared VHDX

Shared VHDX, a new feature in Windows Server 2012 R2, is a boon for administrators wanting to create a Failover Cluster running in Hyper-V virtual machines. Create a VHDX, attach it to the SCSI Controller of a virtual machine, tick "Enable virtual hard disk sharing" under Advanced Features of the Hard Drive (Click the little '+' to access Advanced Features). Repeat for as many virtual machines you want, power them up and you're good to go!

Now you've set up your Failover Cluster and everything's just jolly. Then you get a request to add more storage capacity to the Failover Cluster. At this point, you're thinking - No Sweat! You fire up Hyper-V Manager, create a new VHDX, then go to Failover Cluster Manager to attach it to the first virtual machine as shared, go to the second virtual machine, do the same thing.

BOOM!

Error applying Hard Drive changes

'VM2' failed to add device 'Virtual hard Disk'. (Virtual machine ID XYZ)

Failed to open attachment 'C:\ClusterStorage\Volume1\SharedDisk.vhdx'. Error: 'The requested operation cannot be performed on the virtual disk as it is currently used in shared mode.'.  

Wow - so much for 'No Sweat'! What's going on here?!?

What's going on is that you've very likely not checked the "Enable virtual hard disk sharing" checkbox under Advanced Features before hitting the "Apply" button. Ensure that you've done that and you're good to go.

If you can't be bothered with the GUI, there's always PowerShell!

For every virtual machine that you want to add the Shared VHDX to, run this command (Import the Hyper-V module if you haven't already done so - 'Import-Module Hyper-V'):

Add-VMHardDiskDrive -VMName VM2 -Path C:\ClusterStorage\Volume1\SharedDisk.vhdx -ShareVirtualDisk

If you have Clustered Hyper-V, remember to run the command on the node where the virtual machine is hosted.

That's all, Folks!

Thanks to my colleague and buddy Surinder Singh for pointing this out to me. You really do learn something new everyday.

Comments

  • Anonymous
    January 01, 2003
    Arvind, the hosts need to be clustered to get a special filter driver (svhdxflt.sys) and the VHDX must be on shared storage, either CSV or SMB 3.0.C:ClusterStorage is a special directory under which Cluster Shared Volumes (CSVs) are mounted. C:ClusterStorageVolume1 is a shared disk - not local storage.
  • Anonymous
    January 01, 2003
    The comment has been removed