Share VMDK Data Between VMs Multi-Writer Disk Without Cluster File System
Recently, in working with a client with many different lab environments, there arose the need to copy SQL backups from one lab and restore into a number of other labs. The DB in question was a DB that was around 250 GB. Copying via the network between labs was going to be a nightmare both in terms of performance and in terms of how the lab environments were segregated between the various SQL DBs. Instead of utilizing the network to copy the SQL DB, I had an idea to instead use a shared VMDK between the various lab hosts and allow all the VMs needed to be able to see the VMDK and then copy the data from this shared VMDK between the VMs. Let’s take a look at how to Share VMDK Data Between VMs Multi-Writer Disk Without Cluster File System to take a look at a bit of a hack of the technology to allow using this approach without running a cluster file system between VMs.
Sharing Data with Multi-Writer Disks Use Cases
I have already alluded to the potential use cases of a multi-writer disk shared between servers. Reading and writing data to disk and sharing that data between multiple VMs means you are saving the step of having to duplicate the data by having to copy it across a network and store it on the target VM.
This is especially helpful if you have a large file or large amount of data you need to copy from one VM to another. The data is simply “local” to the VM if you are using a shared multi-writer disk in VMware. This means you only have to write data once.
Additionally, there can be network constraints or complexities between VMs in an environment such as between labs that can be a challenge to copying data in a timely and efficient manner between VMs that may exist in different lab environments.
There is a challenge however with multi-writer VMDKs when looking to use them to share data between VMs in that you need to have a cluster aware file system to be able to simultaneously access the data between various VMs. In the Windows world, this would be using Windows Failover Cluster to negotiate and allow reading and writing between the cluster hosts to the same volume.
In my case, I didn’t need or want to configure a cluster between the VMs in question. I simply wanted to quicky be able to copy and access data between VMs without the time needed to copy across the network, and have the double write penalty of copying to a local disk, then copying across a network to another disk, and then reading that data into the VM. In my case this was a SQL backup.
VMware Multi-Writer VMDK Requirements and Considerations
The following requirements are found in the VMware Multi-Writer Attribute for Shared VMDKs online doc from VMware. What are those ones to note?
- Cluster-aware file systems to avoid corruption
- When using the multiwriter mode, the virtual disk must be eager-zeroed thick (EZT). When creating an EZT disk on vSAN, the disk is not zeroed automatically. If zeroing is required, use the vmkfstools -wcommand to zero-out all blocks. For more information, see VMware knowledge base article 1033570, โPowering on the virtual machine fails with the error: Thin/TBZ disks cannot be opened in multiwriter mode.โ
- Shared VMDKs need not be set to independent persistent mode for the multiwriter attribute
If you notice the first mention is a cluster-aware file system. This is standard protection for a good reason. If you have non cluster aware hosts trying to access (read/write) to the same files, corruption is a good possibility and is probably likely.
Let’s look at a way with Windows Server you can “cheat” this so to speak if you don’t have a cluster configuration such as Windows Failover Cluster services running between VMs.
Share VMDK Data Between VMs Multi-Writer Disk Without Cluster File System
Let’s first look at how to create a multi-writer VMDK to an existing virtual machine. The first thing you need to do is add an additional SCSI Controller for use with the multi-writer VMDKs. I have’t tested this but I don’t think this is absolutely required, but recommended.
After adding the SCSI Controller, you can see the New SCSI controller listed ready to be added.
Now, let’s actually add the new Hard Disk.
Below, for demonstration purposes, I am adding a small 10 GB drive. Based on the requirements for multi-writer, you must use the following configuration settings:
- thick provision eager zeroed disk
- Sharing is set to multi-writer
- Disk mode is set to Independent – Persistent
This will create a new multi-writer VMDK to the source VM. Once the VMDK is created, we can add it to another VM. On your target VM that you would like to add the multi-writer VMDK, select to add Existing Hard Disk.
Select the new multi-writer VMDK from the VMware datastore.
On the second VM and all successive VMs, you will see the VMDK added and the size is greyed out since you can’t change it. A point to note here. Simply adding the multi-writer VMDK will not be recognized as a multi-writer VMDK. Those same settings need to be configured on the second VM as well including sharing and disk mode configuration.
Once the VMDK is added, open disk management and online, initialize, and format the disk.
Here, on the source VM, I first created the SharedVMFolder on the new volume. After “onlining” the disk on the second VM, I created the Test folder to show the behavior.
To understand how the behavior of non-cluster VMs work, notice that since I onlined the disk on the second VM before the second folder was created, the Test folder is not visible.
If I Offline and Online the disk on the second VM, let’s see what happens.
Onlining the disk on the second VM.
Now, we see the folder appear.
You are beginning to see the process to use multi-writer VMDKs for a non-Cluster configuration. Of course, this is not a supported use of this functionality. However, this is a really cool “hack” if you will on using the multi-writer disk.
If you need to have the quickest copy of data between VMs that are not clustered and you can’t or do no want to use network copies for time and efficiency.
To review the process to rapidly copy data using a multi-writer VMDK to copy data or share data between VMs without cluster or network:
- Create the multi-writer VMDK
- Add the multi-writer VMDK to the additional VM(s)
- Online the disk on the source VM you want to copy data from
- Copy the data to the VMDK
- Offline the disk on the source VM
- Online the disk on the target VM
- Copy the data from the VMDK that is now onlined
- Once finished offline the disk
Wrapping Up
Share VMDK Data Between VMs Multi-Writer Disk Without Cluster File System is a cool way although unsupported to copy or quickly share data between VMs without network connectivity. Additionally, as shown, you can do this without clustering such as Windows Failover Clustering although it is not documented as possible. As engineers and architects however, we bend the rules and look for creative ways to solve problems.