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:
-
Create a bootable volume with sufficient storage capacity for all your data.
-
Create a CPU-only virtual machine configuration from the volume in step 1 to serve as an NFS server.
-
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
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 -
Create a security rule to permit traffic to port 2049/TCP on your local subnet (eg: 10.1.1.0/24).
-
Create one or more VMs with your desired configurations and attach the cloud-init NFS clients example script.
-
Optionally, the client configurations can be saved as a Provisioning Profile for future usage.
References:
- Infrahub Docs | Storage Types
- Infrahub Docs | Provisioning Profiles
- Infrahub Docs | Volume Attachment
- Configure NFS Server on Ubuntu - Debian
- Configure NFS Client on Ubuntu - Linux
- Cloud config script examples