Hyper-V, how to share a disk?

3

I am configuring a new Hyper-V server (2012) with a few virtual machines to run a particular software.

I need to save a huge folder on a shared disk that will be accessed on a “read only” basis; so I thought of three possibilities:

  • share a folder on the host and access it using UNC paths
  • create an ISO for that folder and mount as DVD

But I'd prefer to

  • create a virtual disk and attach it to more the one virtual machine.

The last possibility doesn't work, because Hyper-V wants exclusive access to the vhdx file. Do anyone know some way to do this?

AndreaCi

Posted 2013-10-04T12:30:24.160

Reputation: 1 310

You can't attach the same vhd to multiple virtual machines. You can clone the vhd. This isn't unique to Hyper-V either. – Ramhound – 2013-10-04T12:33:47.290

yes, I know, but it's something like 130gb of data – AndreaCi – 2013-10-04T15:06:41.837

In theory you could attempt to force a certain virtual machine to use a certain virtual hdd by editing the configuration file itself. I honestly don't know if what you want is even possible based on what you have shared my educated guess is simply "no, its not possible". – Ramhound – 2013-10-04T15:09:31.083

you can use it, but when you start both VMs a "nice" error message appears warning you that the file is locked – AndreaCi – 2013-10-08T06:59:08.597

Answers

1

You can have shared storage under Windows 2012 Hyper-V but it's not a simple process if you only have a single Hyper-V server.

The assumption on this is that the Hyper-V box is not your DC and that you have some kind of external iSCSI capability (e.g. NAS or other Windows 2012 server).

  1. Create an iSCSI target on your NAS or other server (ideally two targets. 1 for QUORUM 5Gb and 1 for Storage - minimum 130Gb in your case)
  2. Attach the iSCSI target to your HYPER-V box (setup Multi I/O as necessary for your infrastructure)
  3. Create the volumes on the Hyper-V server. 5Gb for your Quorum, whatever you want for shared storage
  4. Install Failover cluster on the Hyper-V server and set it up for a single node.
  5. Setup the large iSCSI target as available storage under failover cluster. this will then appear as c:\ClusterStorage\Volume1

Now that you have shared storage, store your VHD/VHDX in this folder and you can then use the "Enable virtual hard disk sharing" under Disk advanced features for your virtual machine (must be attached to SCSI controller).

I have a single Hyper-V server using a Synology NAS for the iSCSI targets and works perfectly for setting up Windows clusters guest machines. I haven't tried it for Linux yet (and to be honest I found this question looking for whether someone else had already tried it), but will be in the next couple of days.

As long as you don't have your Hyper-V box running as the domain controller, then this should work perfectly.

Steker

Posted 2013-10-04T12:30:24.160

Reputation: 11