How to hot-add a Shared VHDX

How to hot-add a Shared VHDX

  • Comments 2
  • Likes

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
  • Thanks Richard, this is a good feature. I wanted to test this for my laptop's guest cluster setup, but ran into a problem when I tried to add the shared VHDX itself (forget the hot-add scenario.) It gave me an error 'The storage where the virtual hard disk is located does not support virtual hard disk sharing' which I later found to be due to a requirement that the VHDX be on a shared CSV or on Scale-Out File Server. In your demo, you have shown this working on C:\ (local storage), is there something I am missing?

  • 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:\ClusterStorage\Volume1 is a shared disk - not local storage.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment