

# Attach an EBS volume to multiple EC2 instances using Multi-Attach
<a name="ebs-volumes-multi"></a>

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 applications that manage concurrent write operations.

**Pricing and billing**  
There are no additional charges for using Amazon EBS Multi-Attach. You are billed the standard charges that apply to Provisioned IOPS SSD (`io1` and `io2`) volumes. For more information, see [Amazon EBS pricing](https://aws.amazon.com/ebs/pricing/).

**Topics**
+ [

## Considerations and limitations
](#considerations)
+ [Performance for Multi-Attach volumes](ebs-multi-attach-perf.md)
+ [Enable Multi-Attach](working-with-multi-attach.md)
+ [Disable Multi-Attach](disable-multi-attach.md)
+ [NVMe reservations](nvme-reservations.md)

## Considerations and limitations
<a name="considerations"></a>
+ Multi-Attach enabled volumes can be attached to up to 16 instances built on the [ Nitro System](https://docs.aws.amazon.com/ec2/latest/instancetypes/ec2-nitro-instances.html) that are in the same Availability Zone.
+ **Linux instances** support Multi-Attach enabled `io1` and `io2` volumes. **Windows instances** support Multi-Attach enabled `io2` volumes only.
+ The maximum number of Amazon EBS volumes that you can attach to an instance depends on the instance type and instance size. For more information, see [ instance volume limits](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/volume_limits.html).
+ Multi-Attach is supported exclusively on [Provisioned IOPS SSD (`io1` and `io2`) volumes](provisioned-iops.md#EBSVolumeTypes_piops).
+ Multi-Attach for `io1` volumes is available in the following Regions only: US East (N. Virginia), US West (Oregon), and Asia Pacific (Seoul).

  Multi-Attach for `io2` is available in all Regions that support `io2`.
**Note**  
For better performance, consistency, and durability at a lower cost, we recommend that you use `io2` volumes.
+ `io1` volumes with Multi-Attach enabled are not supported with [instances built on the Nitro System](https://docs.aws.amazon.com/ec2/latest/instancetypes/ec2-nitro-instances.html) that support the Scalable Reliable Datagram (SRD) networking protocol only. To use Multi-Attach with these instance types, you must use `io2`.
+ Standard file systems, such as XFS and EXT4, are not designed to be accessed simultaneously by multiple servers, such as EC2 instances. You should use a clustered file system to ensure data resiliency and reliability for your production workloads.
+ Multi-Attach enabled `io2` volumes support I/O fencing. I/O fencing protocols control write access in a shared storage environment to maintain data consistency. Your applications must provide write ordering for the attached instances to maintain data consistency. For more information, see [Use NVMe reservations with Multi-Attach enabled Amazon EBS volumes](nvme-reservations.md).

  Multi-Attach enabled `io1` volumes do not support I/O fencing.
+ Multi-Attach enabled volumes can't be created as boot volumes.
+ Multi-Attach enabled volumes can be attached to one block device mapping per instance.
+ Multi-Attach can't be enabled during instance launch using either the Amazon EC2 console or RunInstances API.
+ Multi-Attach enabled volumes that have an issue at the Amazon EBS infrastructure layer are unavailable to all attached instances. Issues at the Amazon EC2 or networking layer might impact only some attached instances.
+ The following table shows volume modification support for Multi-Attach enabled `io1` and `io2` volumes after creation.    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ebs/latest/userguide/ebs-volumes-multi.html)

  \$1 You can't enable or disable Multi-Attach while the volume is attached to an instance.
+ Multi-Attach enabled volumes are deleted on instance termination if the last attached instance is terminated and if that instance is configured to delete the volume on termination. If the volume is attached to multiple instances that have different delete on termination settings in their volume block device mappings, the last attached instance's block device mapping setting determines the delete on termination behavior.

  To ensure predictable delete on termination behavior, enable or disable delete on termination for all of the instances to which the volume is attached. For more information, see [ Preserve data when an instance is terminated](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/preserving-volumes-on-termination.html).
+ You can monitor a Multi-Attach enabled volume using the CloudWatch Metrics for Amazon EBS volumes. Data is aggregated across all of the attached instances. You can't monitor metrics for individual attached instances. For more information, see [Amazon CloudWatch metrics for Amazon EBS](using_cloudwatch_ebs.md).

# Performance for Multi-Attach Amazon EBS volumes
<a name="ebs-multi-attach-perf"></a>

Each attached instance is able to drive its maximum IOPS performance up to the volume's maximum provisioned performance. However, the aggregate performance of all of the attached instances can't exceed the volume's maximum provisioned performance. If the attached instances' demand for IOPS is higher than the volume's Provisioned IOPS, the volume will not exceed its provisioned performance.

For example, say you create an `io2` Multi-Attach enabled volume with `80,000` provisioned IOPS and you attach it to an `m7g.large` instance that supports up to `40,000` IOPS, and an ` r7g.12xlarge` instance that supports up to `60,000` IOPS. Each instance can drive its maximum IOPS as it is less than the volume's Provisioned IOPS of `80,000`. However, if both instances drive I/O to the volume simultaneously, their combined IOPS can't exceed the volume's provisioned performance of `80,000` IOPS. 

To achieve consistent performance, it is best practice to balance I/O driven from attached instances across the sectors of a Multi-Attach enabled volume.

For more information about IOPS performance for the Amazon EC2 instance types, see [ Amazon EBS optimized instance types](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-optimized.html) in the *Amazon EC2 User Guide*.

# Enable Multi-Attach for an Amazon EBS volume
<a name="working-with-multi-attach"></a>

Multi-Attach enabled volumes can be managed in much the same way that you would manage any other Amazon EBS volume. However, in order to use the Multi-Attach functionality, you must enable it for the volume.

When you create a new volume, Multi-Attach is disabled by default. You can enable Multi-Attach when you create a volume.

You can also enable Multi-Attach for `io2` volumes after creation, but only if they are not attached to any instances. You can't enable Multi-Attach for `io1` volumes after creation.

After you enable Multi-Attach for a volume, you can attach the volume to an instance in the same way that you attach any other EBS volume. For more information, see [Attach an Amazon EBS volume to an Amazon EC2 instance](ebs-attaching-volume.md).

------
#### [ Console ]

**To enable Multi-Attach during volume creation**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Volumes**.

1. Choose **Create volume**.

1. For **Volume type**, choose **Provisioned IOPS SSD (`io1`)** or **Provisioned IOPS SSD (`io2`)**.

1. For **Size** and **IOPS**, choose the required volume size and the number of IOPS to provision.

1. For **Availability Zone**, choose the same Availability Zone that the instances are in.

1. For **Amazon EBS Multi-Attach**, choose **Enable Multi-Attach**.

1. (Optional) For **Snapshot ID**, choose the snapshot from which to create the volume.

1. Set the encryption status for the volume.

   If the selected snapshot is encrypted, or if your account is enabled for [encryption by default](encryption-by-default.md), then encryption is automatically enabled and you can't disable it. You can choose the KMS key to use to encrypt the volume.

   If the selected snapshot is unencrypted and your account is not enabled for encryption by default, encryption is optional. To encrypt the volume, for **Encryption**, choose **Encrypt this volume** and then select the KMS key to use to encrypt the volume.

   You can attach encrypted volumes only to instances that support Amazon EBS encryption. For more information, see [Amazon EBS encryption](ebs-encryption.md).

1. (Optional) To assign custom tags to the volume, in the **Tags** section, choose **Add tag**, and then enter a tag key and value pair. 

1. Choose **Create volume**.

**To enable Multi-Attach after creation**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Volumes**.

1. Select the volume and choose **Actions**, **Modify volume**.

1. For **Amazon EBS Multi-Attach**, choose **Enable Multi-Attach**.

1. Choose **Modify**.

------
#### [ AWS CLI ]

**To enable Multi-Attach during volume creation**  
Use the [create-volume](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-volume.html) command with the `--multi-attach-enabled` option.

```
aws ec2 create-volume \
    --volume-type io2 \
    --multi-attach-enabled \
    --size 100 \
    --iops 2000 \
    --region us-west-2 \
    --availability-zone us-west-2b
```

**To enable Multi-Attach after creation**  
Use the [modify-volume](https://docs.aws.amazon.com/cli/latest/reference/ec2/modify-volume.html) command with the `--multi-attach-enabled` option.

```
aws ec2 modify-volume \
    --volume-id vol-01234567890abcdef \
    --multi-attach-enabled
```

------
#### [ PowerShell ]

**To enable Multi-Attach during volume creation**  
Use the [New-EC2Volume](https://docs.aws.amazon.com/powershell/latest/reference/items/New-EC2Volume.html) cmdlet with the `-MultiAttachEnabled` parameter.

```
New-EC2Volume `
    -VolumeType io2 `
    -MultiAttachEnabled $true `
    -Size 100 `
    -Iops 2000 `
    -Region us-west-2 `
    -AvailabilityZone us-west-2b
```

**To enable Multi-Attach after creation**  
Use the [Edit-EC2Volume](https://docs.aws.amazon.com/powershell/latest/reference/items/Edit-EC2Volume.html) cmdlet with the `-MultiAttachEnabled` parameter.

```
Edit-EC2Volume `
    -VolumeId vol-01234567890abcdef `
    -MultiAttachEnabled $true
```

------

# Disable Multi-Attach for an Amazon EBS volume
<a name="disable-multi-attach"></a>

You can disable Multi-Attach for an `io2` volume only if it is attached to no more than one instance.

You can't disable Multi-Attach for `io1` volumes after creation.

------
#### [ Console ]

**To disable Multi-Attach after creation**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Volumes**.

1. Select the volume and choose **Actions**, **Modify volume**.

1. For **Amazon EBS Multi-Attach**, clear **Enable Multi-Attach**.

1. Choose **Modify**.

------
#### [ AWS CLI ]

**To disable Multi-Attach after creation**  
Use the [modify-volume](https://docs.aws.amazon.com/cli/latest/reference/ec2/modify-volume.html) command with the `-no-multi-attach-enabled` option.

```
aws ec2 modify-volume \
    --volume-id vol-01234567890abcdef \
    --no-multi-attach-enabled
```

------
#### [ PowerShell ]

**To disable Multi-Attach after creation**  
Use the [Edit-EC2Volume](https://docs.aws.amazon.com/powershell/latest/reference/items/Edit-EC2Volume.html) cmdlet with the `-MultiAttachEnabled` parameter.

```
Edit-EC2Volume `
    -VolumeId vol-01234567890abcdef `
    -MultiAttachEnabled $false
```

------

# Use NVMe reservations with Multi-Attach enabled Amazon EBS volumes
<a name="nvme-reservations"></a>

Multi-Attach enabled `io2` volumes support NVMe reservations, which is a set of industry-standard storage fencing protocols. These protocols enable you to create and manage reservations that control and coordinate access from multiple instances to a shared volume. Reservations are used by shared storage applications to ensure data consistency.

**Topics**
+ [

## Requirements
](#nvme-reservations-reqs)
+ [

## Enabling support for NVMe reservations
](#nvme-reservations-enable)
+ [

## Supported NVMe Reservation commands
](#nvme-reservations-commands)
+ [

## Pricing
](#nvme-reservations-cost)

## Requirements
<a name="nvme-reservations-reqs"></a>

NVMe reservations is supported with Multi-Attach enabled `io2` volumes only. Multi-Attach enabled volumes can be attached only to instances built on the Nitro system.

NVMe reservations is supported with the following operating systems:
+ SUSE Linux Enterprise 12 SP3 and later
+ RHEL 8.3 and later
+ Amazon Linux 2 and later
+ Windows Server 2016 and later

**Note**  
For supported Windows Server AMIs dated 2023.09.13 and later, the required NVMe drivers are included. For earlier AMIs, you must update to NVMe driver version 1.5.0 or later. For more information, see [AWS NVMe drivers](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/aws-nvme-drivers.html).

If you're using EC2Launch v2 to initialize your disks, you must upgrade to version **2.0.1521** or later. For more information, see [Use the EC2Launch v2 agent](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2launch-v2.html).

## Enabling support for NVMe reservations
<a name="nvme-reservations-enable"></a>

Support for NVMe reservations is enabled by default for all Multi-Attach enabled `io2` volumes created after **September 18, 2023**.

To enable support for NVMe reservations for existing `io2` volumes created before September 18, 2023, you must detach all instances from the volume and then reattach the required instances. All attachments made after detaching all of the instances will have NVMe reservations enabled.

## Supported NVMe Reservation commands
<a name="nvme-reservations-commands"></a>

Amazon EBS supports the following NVMe Reservation commands:

**Reservation Register**  
Registers, unregisters, or replaces a reservation key. A registration key is used to identify and authenticate an instance. Registering a reservation key with a volume creates an association between the instance and the volume. You must register the instance with the volume before that instance can acquire a reservation.

**Reservation Acquire**  
Acquires a reservation on a volume, preempts a reservation held on a namespace, and aborts a reservation held on a volume. The following reservation types can be acquired:  
+ Write Exclusive Reservation
+ Exclusive Access Reservation
+ Write Exclusive - Registrants Only Reservation
+ Exclusive Access - Registrants Only Reservation
+ Write Exclusive - All Registrants Reservation
+ Exclusive Access - All Registrants Reservation

**Reservation Release**  
Releases or clears a reservation held on a volume.

**Reservation Report**  
Describes the registration and reservation status of a volume.

## Pricing
<a name="nvme-reservations-cost"></a>

There are no additional costs for enabling and using Multi-Attach.