0

Is file sharing by simply using Hyper-V Shared VHDX on CSV attached to two VMs possible ?

I'm testing SVHDX in my environment and I can't get it working. We have setup failover cluster and CSV backed by SAN over FC, I have put SVHDX on CSV and attached that disk to two VMs. Now I have inconsistency on the disk as I save few files on the VM1 they are not visible on the VM2 and CHKDSK is reporting errors. I can even create files with same name on shared disk.

khorvat
  • 113
  • 6

2 Answers2

2

Yes. You can not share a file system between mupltiple computers UNLESS THE FILE SYSTEM IS EXPLICITLY DESIGNED TO DO THAT. Because computers cache the meta information and assume they are the owner.

TomTom
  • 50,857
  • 7
  • 52
  • 134
  • What is the purpose of shared VHDX then ? There are many articles describing shared data storage using svhdx (e.g. http://channel9.msdn.com/Events/TechEd/Europe/2013/MDC-B311#fbid= second part) so it's not clear to me how to get this working and if it's not possible as you claim then what should be used for file sharing in combination with svhdx or csv ? – khorvat Feb 05 '15 at 09:19
  • The purpose is to be able to simulate a cluster with a shared volume WITHOUT having to have a SAN. I can simply put up multiple VM's and use a shared VHDX as shared volume. THis is, btw., documented as goal of this feature ;) Plus other people may use cluster aware file systems - it is not like those do not exist. – TomTom Feb 05 '15 at 10:14
  • So if file sharing is possible "_by simply using Hyper-V Shared VHDX on CSV attached to two VMs_" do you know what may be causing the files to not show up on other VM ? – khorvat Feb 05 '15 at 10:35
  • No, it is not. Man, try READING what I said. VHDX sharing is possible - now you need a FILE SYSTEM THAT SUPPORTS IT, and Windows only has that as CSV (which is not supported for file sharing). Get it? It is NOT possible with NTFS as you know it. – TomTom Feb 05 '15 at 10:37
  • Sorry your answer is _Yes_ to my question and that confused me. – khorvat Feb 05 '15 at 11:00
1

Shared VHDX is block sharing, not file sharing.

Now for a little digression in terms, since you're far from the first person to ask this question. A disk is a block device. It works by responding to commands like "read block 23971" and "write block 1082." A file system is a way of storing data that maps onto a block device. When you write a file, the file system code finds some free blocks on the disk, and writes your data into them. And perhaps even more importantly for this discussion, it writes other data onto the disk recording the name of the file, what blocks the file is stored in, who has access to the file, etc.

If two different machines are using the same block device, they need to coordinate their actions, or they'll clobber each other, each thinking that they get to decide where data goes on the disk and how the location of that data is recorded.

So, if you want to share a disk, the most common way to do it is to give it to one computer and have that computer own the disk, sharing it with others through a network file system like NFS or SMB. All the other computers ask for data over the network. The file server owns the disk and manages it. The clients see only files. The owner (the file server) sees files mapped onto blocks.

In a few situations, though, you want two or more computers to use a block device (a disk) directly. To do this, you need to hook those two or more computers tightly together so that they can coordinate their actions. This is called "forming a cluster." Then you need to run a cluster file system on the disk. When running Windows, without any third-party software, your only choice for a cluster file system is CSVFS. When running Linux or other OSes, you have some other options.

Again, my recommendation is to use a file server for your task. But the purpose of Shared VHDX is to allow a cluster of VMs to run a cluster file system.

This would be useful primarily (when Windows is the guest) when you want to build a SQL Server cluster out of two VMs, so that SQL itself is highly available.

Or you can build a multi-VM Windows File Server cluster using Shared VHDX. You might do this because you want your file server cluster to be available to its clients even when one of the physical hosts dies.

Without Shared VHDX, this hypothetical SQL or File Server cluster would fall off the network for a while if one of the physical hosts in your environment dies. If the hosts are themselves clustered, the VM would be restarted on another node as soon as the failure occurs. But there will be some downtime from the point of view of the clients. (With SQL Server, there will still be a little downtime, but the clients can manage that. With the File Server cluster, you can make it so that the clients, as long as they're running SMB 3.0 or later, experience automatic failover and don't drop connections.)

Jake Oshins
  • 5,116
  • 17
  • 15
  • When you say _you want two or more computers to use a block device (a disk) directly_ are you referring to the guest cluster where svhdx can be used to form a shared storage optionally a CSV as per https://technet.microsoft.com/en-us/library/dn265980.aspx Step 4 ? – khorvat Feb 06 '15 at 07:52
  • Yes, I am. Your link is a cookbook for creating a cluster of guest VMs running Windows, but there are other possible uses, all of a similar nature. – Jake Oshins Feb 06 '15 at 18:30
  • Documentation I's very confusing for non system admins, so if I create a guest cluster and share svhdx between few VMs add svhdx to shared guest cluster storage would I be able to share files and use svhdx as ordinary disks or do I need SOFS ? – khorvat Feb 06 '15 at 19:10
  • If you create a guest cluster and put CSVFS on top of it, then all the members of that guest cluster will see that (virtual) disk as a local disk, and they will all share it, seeing the files on that disk symmetrically and safely. But so what? The only point in doing that is so that you can run a Scale-Out File Server on top of that, or a SQL server on top of that. If there was any other purpose, then you'd be better served by just giving the VHD to a single VM and using that VM as a file server. – Jake Oshins Feb 06 '15 at 22:27
  • So it's recommended to use the SOFS on top of guest CSV (via SVHDX) and not CSV directly for file sharing among the VMs ? – khorvat Feb 07 '15 at 11:16
  • The thing that you really need to know is that CSV works by using SMB (the file server protocol) to move data whenever the node in question doesn't own it. So joining several computers together with CSV basically does the same thing as a file server, except in one special situation: When you have a really big file that is exclusively owned by one node, that node can read and write to it directly, provided that the file isn't being changed in size -- i.e. the data in it is being re-written. This is exactly what Hyper-V and SQL Server do. File servers are really good at small files. – Jake Oshins Feb 08 '15 at 01:43
  • We are using SAN underneath the CSV and not storage spaces with node "physical" disks so should this work with big files ? – khorvat Feb 08 '15 at 07:31
  • Whether a SAN is turning a pile of disks into a volume or whether that's done with Storage Spaces is of no particular relevance to this discussion. My point is that you will be much happier with a file server. – Jake Oshins Feb 09 '15 at 05:51