Can I attach a single volume to multiple virtual machines?

NFS sharing can be used to share a single volume between multiple virtual machines.

A volume can only be attached to a single virtual machine at a time due to the lack of support for parallel access to a single disk by most operating systems and file systems.

However, NFS sharing can be used to share a single volume between multiple virtual machines.

Follow these steps:

  1. Create a bootable volume with sufficient storage capacity for all your data.

  2. Create a CPU-only virtual machine configuration from the volume in step 1 to serve as an NFS server.

  3. Use a cloud-init script to install packages and enable NFS sharing.

    Example of an  NFS server cloud-init script:
    #cloud-config

    packages:
    - nfs-kernel-server
    package_update: true

    runcmd:
    - mkdir -p /data/nfshare
    - echo "/data/nfshare *(rw,no_root_squash)" >> /etc/exports
    - exportfs -ravs
    Note: "/data/nfshare" and "*(rw,no_root_squash)" should be edited according to the required behavior.

    Example of an NFS client cloud-init script:
    #cloud-config

    packages:
    - nfs-common
    package_update: true

    mounts:
    - [ "10.0.0.128:/data/nfshare", "/mnt", "nfs", "defaults", "0","0" ]

    runcmd:
    - mount /mnt
    Note: "10.0.0.128:/data/nfshare" and "/mnt" must be changed according to the required behavior.
  4. Create a security rule to permit traffic to port 2049/TCP on your local subnet (eg: 10.1.1.0/24).

  5. Create one or more VMs with your desired configurations and attach the cloud-init NFS clients example script.

  6. Optionally, the client configurations can be saved as a Provisioning Profile for future usage.


References:

 

For further assistance, don't hesitate to reach out to us at:

Support Email: [email protected]

Sales Contact: [email protected]

Phone: +44 (0) 203 475 3402


nexgen logo

Please check out our Website and Social Media