AWS EBS Multi-Attach
What is EBS Multi-Attach?
Amazon EBS Multi-Attach enables you to attach a single Provisioned IOPS SSD (io1 or io2) volume to multiple instances that are in the same Availability Zone. You can attach multiple Multi-Attach enabled volumes to an instance or set of instances. Each instance to which the volume is attached has full read and write permission to the shared volume. Multi-Attach makes it easier for you to achieve higher application availability in clustered Linux applications that manage concurrent write operations.
Limitations of EBS Multi-Attach:
There are a few limitations to be aware of when using Amazon Elastic Block Store (EBS) Multi-Attach volumes:
Only Nitro-based EC2 instances can use Multi-Attach volumes. This means that instances launched from certain older instance types or virtualization types will not be able to use Multi-Attach volumes
Multi-Attach volumes can only be attached to instances in the same availability zone. This means that you cannot use Multi-Attach to share a volume across multiple availability zones
Multi-Attach volumes can only be attached to instances that are in the running or stopped state. You cannot attach a Multi-Attach volume to an instance that is in the terminated state
Only certain types of workloads are suitable for Multi-Attach. High-performance workloads such as databases, big data, and HPC could be designed to use Multi-attach
Multi-Attach volumes can only be used with provisioned IOPS SSD (io1) and General Purpose SSD (gp2) volumes, and not with magnetic (standard) volumes
Multi-Attach volumes are currently only available in certain regions
The maximum IOPS and throughput limits per volume are lower when using Multi-Attach compared to when using a single-attach volume
Hands-on Lab Overview
The aim of this hands-on lab is to create EBS Multi-Attach and see it in action. We will create two EC2 instances (FirstInstance
and SecondInstance
) and one EBS volume with Multi-Attach enabled functionality. This EBS volume will be attached to the two EC2 instances. By accessing this EBS volume from one EC2 machine, we will format it, mount and create a file demoFile
. We will access this file from the second EC2 machine. Then, we will create a file secondDemoFile
on the second EC2 instance and access it from the first EC2 instance.
Hands-on Lab
Create an SSH key pair:
Create two EC2 instances with different AMIs: one with Ubuntu (AMI ID: ami-053b0d53c279acc90) and the second with Linux 2 (AMI ID: ami-09538990a0c4fe9be). Choose the instance type
t3.small
for both EC2 machines.Then, create an EBS Multi-Attach volume:
Attach EBS Multi-Attach Volume to the two EC2 instances:
Check whether the volume was attached to the two EC2 instances:
Connect to the first EC2 instance above (
FirstInstance
) running Ubuntu via AWS EC2 Connect.
When the connection is established, list all available block devices on the instance to identify the block device that corresponds to your EBS volume:
lsblk
As we can see as a result of
lsblk
command, there is no mount point for the attached EBS volume.Format the EBS Volume:
sudo mkfs.ext4 /dev/nvme1n1
Mount the EBS Volume:
Now, create a directory where you'll mount the volume:
sudo mkdir /mnt/myvolume
Mount the volume to this directory:
sudo mount /dev/nvme1n1 /mnt/myvolume
Connect to the second EC2 instance and identify the block device that corresponds to your EBS volume with the command
lsblk
.Mount the EBS Volume:
Now, create a directory where you'll mount the volume and mount the volume to this directory:
Access the
demoFile
from the second EC2 instance:Create another file
secondDemoFile
on the second EC2 instance:Finally, to access
secondDemoFile
from the first EC2 instance, first, we need to unmount the EBS volume and mount it again to see the changes made by other instances.
References
Subscribe to my newsletter
Read articles from Karlygash Yakiyayeva directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Karlygash Yakiyayeva
Karlygash Yakiyayeva
Postgraduate in Communications Engineering with working experience in the Support Desk and self-study in software development.