Attach an EBS volume to multiple EC2 instances using Multi-Attach

Search for a command to run...

No comments yet. Be the first to comment.
AWS Agent Plugins let AI coding agents deploy, architect, and operate on AWS. Here's what that means for the future of DevOps.

AWS Storage Gateway bridges your on-premises infrastructure with Amazon's cloud storage — letting you use familiar protocols like NFS, SMB, and iSCSI while your data lives safely in S3, EBS, or Glacie

This AZ-104 domain emphasizes secure identity management and efficient resource governance, which are essential for Azure administrators to ensure compliance and cost control. Overview of Azure Identi

Scaling your EC2 instances to match dynamic workloads can be challenging. Amazon EC2 Auto Scaling simplifies this with target tracking scaling policies, a powerful feature that automatically adjusts capacity to maintain optimal performance and cost e...

CloudCubes by Jinesh
45 posts
Cloud Infrastructure Consultant
Find me here : jineshkumar.bio.link
https://jineshkumar.com
On this page
Introduction
Amazon Elastic Block Store (EBS) is a cornerstone of AWS storage solutions, offering persistent block-level storage for EC2 instances. While EBS volumes are typically attached to a single instance.
# EBS Multi-Attach breaks this mold, allowing a single volume to be attached to multiple EC2 instances in the same Availability Zone (AZ). This feature is invaluable for clustered applications requiring shared storage for high availability (HA) or fault tolerance. In this guide, we’ll explore how to configure Multi-Attach, use cases, commands, and best practices.
Example Illustration of EBS Multi-Attach (Image Reference - AWS)

Clustered Databases: Deploy databases like SQL Server Failover Clusters or Oracle RAC where multiple nodes require access to shared data.
High Availability Applications: Applications needing redundant compute nodes with shared storage for failover.
Real-Time Collaboration: Workloads requiring simultaneous read/write access to shared data (with proper file system coordination).
Volume Type: Only Provisioned IOPS SSD (io1/io2) volumes support Multi-Attach.
Availability Zone: All attached instances must reside in the same AZ.
File System: Use a cluster-aware file system (e.g., GFS2, Windows Failover Cluster) to avoid data corruption.
Instance Compatibility: Instances must support EBS encryption if the volume is encrypted.
Navigate to the EC2 Console → Volumes → Create Volume.
Configure:
Volume Type: io1 or io2
Size & IOPS: Define size (GiB) and provisioned IOPS.
Availability Zone: Match the AZ of your target instances.
Multi-Attach: Check Enable Multi-Attach.
(Optional) Configure encryption or tags.
Click Create Volume.
aws ec2 create-volume \
--volume-type io2 \
--size 100 \
--iops 3000 \
--availability-zone us-east-1a \
--multi-attach-enabled
After creation, attach the volume to multiple instances in the same AZ.
# Attach to Instance 1 Replace with your instance ID
aws ec2 attach-volume \
--volume-id vol-12345abc \
--instance-id i-0abcd1234 \
--device /dev/sdf
# Attach to Instance 2 Replace with your instance ID
aws ec2 attach-volume \
--volume-id vol-12345abc \
--instance-id i-0efgh5678 \
--device /dev/sdf
Note: Only io2 volumes can have Multi-Attach enabled post-creation (if unattached).
Select the volume → Actions → Modify Volume.
Check Enable Multi-Attach → Modify.
aws ec2 modify-volume \
--volume-id vol-12345abc \
--multi-attach-enabled
Imagine deploying a SQL Server Failover Cluster across two EC2 instances (i-0abcd1234 and i-0efgh5678) in us-east-1a.
Create a Multi-Attach Volume:
aws ec2 create-volume --volume-type io2 --size 500 --iops 5000 \
--availability-zone us-east-1a --multi-attach-enabled
Attach to Both Instances:
# Attach to primary instance
aws ec2 attach-volume --volume-id vol-12345abc --instance-id i-0abcd1234 --device /dev/sdf
# Attach to secondary instance
aws ec2 attach-volume --volume-id vol-12345abc --instance-id i-0efgh5678 --device /dev/sdf
Configure Windows Failover Cluster:
Initialize the disk as NTFS or ReFS on the primary instance.
Add the disk to the cluster shared volumes (CSV) in Windows Server Failover Cluster Manager.
To disable Multi-Attach, ensure the volume is attached to no more than one instance.
Select the volume → Actions → Modify Volume.
Uncheck Enable Multi-Attach → Modify.
aws ec2 modify-volume \
--volume-id vol-12345abc \
--no-multi-attach-enabled
Cluster-Aware File Systems: Always use file systems designed for concurrent access (e.g., GFS2, CSV).
I/O Coordination: Applications must handle concurrent writes to avoid data corruption.
Monitoring: Use Amazon CloudWatch to track volume performance (VolumeQueueLength, BurstBalance).
Volume Types: Only io1 and io2 support Multi-Attach.
AZ Bound: All instances must be in the same AZ.
io1 Restriction: Multi-Attach cannot be enabled on io1 after creation.
Encryption: Encrypted volumes require compatible instances.
The following table shows volume modification support for Multi-Attach enabled io1 and io2 volumes after creation.
| Modification Option | io2 Volumes | io1 Volumes |
| Modify volume type | ✗ | ✗ |
| Modify volume size | ✓ | ✗ |
| Modify provisioned IOPS | ✓ | ✗ |
| Enable Multi-Attach | ✓ * | ✗ |
| Disable Multi-Attach | ✓ * | ✗ |
* You can't enable or disable Multi-Attach while the volume is attached to an instance.
Attachment Failure: Verify AZ alignment, instance support for encryption, and volume type.
Data Corruption: Ensure the application or file system handles concurrent writes.
EBS Multi-Attach is a game-changer for clustered workloads needing shared storage. By following this guide, you can configure Multi-Attach for io1/io2 volumes, attach them to multiple instances, and deploy highly available applications. Remember to use cluster-aware file systems and monitor performance to avoid bottlenecks.
Further Reading:
Clustered File Systems for Linux - Attach an EBS volume to multiple EC2 instances using Multi-Attach
By mastering EBS Multi-Attach, you unlock new possibilities for building resilient, high-performance clustered File System architectures on AWS.
I hope this blog post has been helpful. If you have any further questions or encounter any issues, please feel free to leave a comment below.
Thank you for reading! Happy Learning!
Like and Follow for more content.
Thank you,
Jineshkumar Patel