Mount a File Store on multiple VMs
File Store is designed for shared access, allowing multiple virtual machines (VMs) to mount the same File Store simultaneously. This guide shows you how to mount a File Store on multiple VMs and configure proper access.
Prerequisites
Section titled “Prerequisites”Before you begin:
- A File Store created and in
Availablestatus - Two or more VMs in the same zone and VPC as the File Store
- The File Store endpoint IP (from the File Store status)
- NFS client installed on all VMs
Architecture
Section titled “Architecture” File Store (10.100.0.10) | | VPC Network ______________|______________ | | VM-1 (10.100.0.5) VM-2 (10.100.0.6) /mnt/filestore /mnt/filestore | | Shared Data Shared DataAll VMs connect to the same File Store endpoint through the VPC network.
Step 1: Verify File Store status
Section titled “Step 1: Verify File Store status”First, verify your File Store is available and get the endpoint IP:
evroc storage filestore get my-filestoreNote the endpoint and exportPath from the output:
status: nfs: endpoint: 10.100.0.10 exportPath: /Step 2: Prepare each VM
Section titled “Step 2: Prepare each VM”On each VM that will mount the File Store:
-
Install NFS client:
Ubuntu/Debian:
Terminal window sudo apt-get updatesudo apt-get install -y nfs-commonRHEL/CentOS/Rocky Linux:
Terminal window sudo yum install -y nfs-utils -
Create mount point:
Terminal window sudo mkdir -p /mnt/filestore
Step 3: Mount on each VM
Section titled “Step 3: Mount on each VM”Mount the File Store on each VM using the endpoint IP:
# Replace `<filestore-endpoint>` with your File Store endpointsudo mount -t nfs4 -o nfsvers=4.1,_netdev <filestore-endpoint>:/ /mnt/filestoreVerify the mount:
df -h | grep filestoreStep 4: Test shared access
Section titled “Step 4: Test shared access”To verify shared access is working:
On VM-1
Section titled “On VM-1”Create a test file:
echo "Hello from VM-1" | sudo tee /mnt/filestore/shared-test.txtOn VM-2
Section titled “On VM-2”Read the file:
cat /mnt/filestore/shared-test.txt# Output: Hello from VM-1Create another file:
echo "Hello from VM-2" | sudo tee /mnt/filestore/vm2-test.txtBack on VM-1
Section titled “Back on VM-1”List all files:
ls -la /mnt/filestore/# Output shows both shared-test.txt and vm2-test.txtConfigure automatic mounting
Section titled “Configure automatic mounting”To mount automatically on boot, add entries to /etc/fstab on each VM:
# Replace `<filestore-endpoint>` with your endpoint IPecho "<filestore-endpoint>:/ /mnt/filestore nfs4 nfsvers=4.1,_netdev 0 0" | sudo tee -a /etc/fstabSecurity considerations
Section titled “Security considerations”Network access
Section titled “Network access”Ensure VMs can reach the File Store endpoint:
- VMs must be in the same VPC as the File Store
- By default, security groups already allow NFS traffic (TCP port 2049) within the same VPC
- Only configure custom security group rules if you have removed default security groups from your VMs
File permissions
Section titled “File permissions”File Store uses standard Linux file permissions. To ensure proper access across VMs:
- Use consistent user IDs - Ensure users have the same UID across VMs
- Set up groups - Use groups for shared access
- Configure ACLs - Use Access Control Lists for fine-grained control
Example: Create a shared group
# On each VM, create a group with the same GIDsudo groupadd -g 2000 sharedusers
# Add users to the groupsudo usermod -aG sharedusers username
# Set group ownership on filessudo chown -R :sharedusers /mnt/filestore/shared-directorysudo chmod 2775 /mnt/filestore/shared-directoryThe 2775 permission sets the setgid bit, ensuring new files inherit the group.
Performance considerations
Section titled “Performance considerations”When multiple VMs access the same File Store:
- Total throughput is shared across all mounts
- Concurrent access to the same files may impact performance
- Caching on each VM may cause temporary inconsistencies
Best practices
Section titled “Best practices”- Distribute read-heavy workloads across multiple File Stores
- Avoid having multiple VMs write to the same file simultaneously
- Use application-level locking if coordinating access
- Consider separate File Stores for different workload types
Troubleshooting
Section titled “Troubleshooting”Mount fails on some VMs
Section titled “Mount fails on some VMs”If mounting works on some VMs but not others:
-
Check network connectivity:
Terminal window ping <filestore-endpoint> -
Verify NFS port is accessible:
Terminal window nc -zv <filestore-endpoint> 2049 -
Check security group rules allow traffic from the VM
Permission denied errors
Section titled “Permission denied errors”If you see permission errors:
-
Verify the mount succeeded:
Terminal window mount | grep filestore -
Check file permissions:
Terminal window ls -la /mnt/filestore -
Ensure users have appropriate permissions
Stale file handle errors
Section titled “Stale file handle errors”If a VM sees “stale file handle” errors:
-
Unmount the File Store:
Terminal window sudo umount /mnt/filestore -
Remount:
Terminal window sudo mount -t nfs4 -o nfsvers=4.1,_netdev <endpoint>:/ /mnt/filestore
This can happen if the File Store recovers after a failure while a VM had files open.
See Also
Section titled “See Also”- Configure mount options - Optimize mount settings
- Configure security groups - Control network access
- Troubleshooting - Common issues and solutions