Attach an Amazon EBS volume to an instance - Amazon EBS
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Attach an Amazon EBS volume to an instance

You can attach an available EBS volume to one or more of your instances that is in the same Availability Zone as the volume.

For information about adding EBS volumes to your instance at launch, see instance block device mapping.

Considerations
  • Determine how many volumes you can attach to your instance. 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.

  • If a volume is encrypted, you can attach it only to an instance that supports Amazon EBS encryption. For more information, see Supported instance types.

  • If a volume has an Amazon Web Services Marketplace product code:

    • You can attach a volume only to a stopped instance.

    • You must be subscribed to the Amazon Web Services Marketplace code that is on the volume.

    • The instance's configuration, such as its type and operating system, must support that specific Amazon Web Services Marketplace code. For example, you cannot take a volume from a Windows instance and attach it to a Linux instance.

    • Amazon Web Services Marketplace product codes are copied from the volume to the instance.

You can attach a volume to an instance using one of the following methods.

Console
To attach an EBS volume to an instance using the console
  1. Open the Amazon EC2 console at https://console.amazonaws.cn/ec2/.

  2. In the navigation pane, choose Volumes.

  3. Select the volume to attach and choose Actions, Attach volume.

    Note

    You can attach only volumes that are in the Available state.

  4. For Instance, enter the ID of the instance or select the instance from the list of options.

    Note
    • The volume must be attached to an instance in the same Availability Zone.

    • If the volume is encrypted, it can only be attached to instance types that support Amazon EBS encryption. For more information, see Amazon EBS encryption.

  5. For Device name, do one of the following:

    • For a root volume, select the required device name from the Reserved for root volume section of the list. Typically /dev/sda1 or /dev/xvda for Linux instances depending on the AMI, or /dev/sda1 for Windows instances.

    • For data volumes, select an available device name from the Recommended for data volumes section of the list.

    • To use a custom device name, select Specify a custom device name and then enter the device name to use.

    This device name is used by Amazon EC2. The block device driver for the instance might assign a different device name when mounting the volume. For more information, see device names on Linux instances or device names on Windows instances.

  6. Choose Attach volume.

  7. Connect to the instance and mount the volume. For more information, see Make an Amazon EBS volume available for use.

Amazon CLI
To attach an EBS volume to an instance using the Amazon CLI

Use the attach-volume command.

Tools for Windows PowerShell
To attach an EBS volume to an instance using the Tools for Windows PowerShell

Use the Add-EC2Volume command.

Note
  • If you attempt to attach a number of volumes that exceeds the instance type's volume limit, the request fails. For more information, see Instance volume limits.

  • In some situations, you may find that a volume other than the volume attached to /dev/xvda or /dev/sda has become the root volume of your instance. This can happen when you have attached the root volume of another instance, or a volume created from the snapshot of a root volume, to an instance with an existing root volume. For more information, see Boot from the wrong volume.