Ubuntu – Share Files via Shared Disc Across Multiple VMs

azurefilesystemsmountpartitionUbuntu

I am trying to share a single disk across multiple VM's (Ubuntu 18). The VM's are hosted in Azure and the disk is an Azure Managed Disk. I've attached the disk to both VM's and have mounted them. I can see the partition on each, as well as the test file I've created, test.txt. However, updates to the contents of the txt file while SSH'ed into VM1 are not reflected in VM22. Instead, the VM2 shows the prior value until I unmount and remount the drive.

I'm new to Ubuntu/Linux, and am trying to figure out where to look. My initial thoughts…

  • Perhaps the filesystem I'm using (gpt) cannot support multiple, concurrent access in this manner and I must use something else? If so, what is more suitable?
  • The VM seems to take a copy of the file when it's mounted and writes are not shared.
  • Perhaps this is the problem and this can be turned off?
  • Perhaps this is a problem with Azure, although I no longer believe it to be.
  • Perhaps there is a permissions issue because the user accounts differ between machines. I know Linux includes permissions on a file + directory basis as a first-class concern.

Any other thoughts?

Best Answer

Shared managed disks need to be used in conjunction with a cluster manager or similar to handle the concurrancy, the Azure feature is really just about being able to technically attach it to more than one VM. See the docs here:

Shared managed disks don't natively offer a fully managed file system that can be accessed using SMB/NFS. You need to use a cluster manager, like Windows Server Failover Cluster (WSFC), or Pacemaker, that handles cluster node communication and write locking.

As Tero mentioned, what you have done is a recipie for data loss.

Related Topic