Amazon Elastic Compute Cloud
User Guide (API Version 2013-02-01)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

Attaching a Volume to an Instance

This section describes how to attach a volume that you created to an instance.

The following table lists the available device names on Amazon EC2. You can specify these names when attaching a volume to a running instance or when attaching a volume when launching an instance using a block device mapping. The block device driver for the instance assigns the actual volume names when mounting the volumes, and these names can be different than the names that Amazon EC2 recommends. For more information about the instance store, see Amazon EC2 Instance Store. For information about the root device storage, see Amazon EC2 Root Device Volume.

Instance TypePossible for ConnectionReserved for RootInstance Store VolumesRecommended for Connection

Linux / UNIX

/dev/sd[a-z]

/dev/sd[a-z][1-15]

/dev/hd[a-z]

/dev/hd[a-z][1-15]

/dev/sda1

/dev/sd[b-e]

/dev/sd[f-p]

/dev/sd[f-p][1-6]

Windows

xvd[a-p]

/dev/sda[1-2]

/dev/sd[b-e]

/dev/sda1

xvd[a-e]

xvd[f-p]

Important

For Linux/UNIX instance types, we've received reports that some custom kernels might have restrictions that limit use to /dev/sd[f-p] or /dev/sd[f-p][1-6]. If you're having trouble using /dev/sd[q-z] or /dev/sd[q-z][1-6], try switching to /dev/sd[f-p] or /dev/sd[f-p][1-6].

After you have mapped a device using one of these device names, it is mapped to either a scsi drive (sd[a-z]) or an xvd drive (xvd[a-p]), depending on the block device driver of your kernel. If the kernel has an xvd driver, the device is mapped to xvd[a-p]. If the kernel doesn't have an xvd driver, the device is mapped to sd[a-z][1-15].

Base Windows and CentOS HPC (Cluster Compute) images come bundled with an xvd driver, so the devices on Windows and CentOS HPC (Cluster Compute) instances are mapped to xvd[a-p]. The xvd drivers (xvd[a-p]) don't support the use of trailing numbers (xvd[a-p][1-15]). We recommend that you use device names to xvd[a-p] on instances that have xvd drivers.

Depending on the size of your instance, Amazon EC2 provides instance store volumes on sd[b-e] (on Linux/UNIX) or xvd[a-e] (on Windows and CentOS HPC). Although you can connect your Amazon EBS volumes using these device names, we highly recommend that you don't because the behavior can be unpredictable.

An Amazon EC2 Windows AMI comes with an additional service installed, the Ec2Config Service. The Ec2Config Service runs as a local system and performs various functions to prepare an instance when it first boots up. After the devices have been mapped with the drives, the Ec2Config Service then initializes and mounts the drives. The root drive is initialized and mounted as c:\. The instance stores that comes attached to the instance are initialized and mounted as d:\, e:\, and so on. By default, when an EBS volume is attached to a Windows instance, it may show up as any drive letter on the instance. You can change the settings of the Ec2Config Service to set the drive letters of the EBS volumes per your specifications. For more information, go to Using Ec2Config in the Amazon Elastic Compute Cloud Microsoft Windows Guide.

AWS Management Console

To attach an Amazon EBS volume to an instance

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. Click Volumes in the navigation pane.

    The console displays a list of current volumes.

  3. Select a volume and click Attach Volume.

    The Attach Volume dialog box appears.

  4. Select the instance to attach the volume to from the Instance list box (only instances in the same Availability Zone as the volume are displayed).

  5. Select how the device is exposed to the instance from the Device list box.

  6. Click Attach to attach the volume to the instance.

Note

The volume and instance must be in the same Availability Zone.

Note

Windows instances use either RedHat or Citrix paravirtual drivers. Regardless of which drivers you are using, you can attach up to 16 EBS volumes using the Amazon EC2 console. If your Windows instance is using Citrix drivers, you can attach up to a total of 25 EBS volumes using the EC2 CLI. To upgrade your Windows instance from RedHat to Citrix paravirtual drivers, see Upgrading Your PV Drivers on Your Windows AMI.

Note

If a volume has an AWS Marketplace product code:

  • The volume can only be attached to the root device of a stopped instance.

  • You must be subscribed to the AWS Marketplace code that is on the volume.

  • The configuration (instance type, operating system) of the instance must support that specific AWS Marketplace code. For example, you cannot take a volume from a Windows instance and attach it to a Linux instance.

  • AWS Marketplace product codes are copied from the volume to the instance.

For an overview of the AWS Marketplace, see https://aws.amazon.com/marketplace/help/200900000. For details on how to use the AWS Marketplace, see AWS Marketplace.

Command Line Interface

To attach an Amazon EBS volume to an instance, use ec2-attach-volume.

PROMPT>  ec2-attach-volume volume_id -i instance_id -d device

Amazon EC2 returns information using this syntax.

ATTACHMENT volume_id instance_id device attaching date_time 

This example attaches volume vol-4d826724 to instance i-6058a509 in Linux and UNIX and exposes it as device /dev/sdh.

PROMPT>  ec2-attach-volume vol-4d826724 -i i-6058a509 -d /dev/sdh
ATTACHMENT vol-4d826724 i-6058a509 /dev/sdh attaching 2010-03-30T13:58:58+0000 

This example attaches volume vol-4d826724 to instance i-6058a509 in Windows and exposes it as device xvdf.

PROMPT>  ec2-attach-volume vol-4d826724 -i i-6058a509 -d xvdf
ATTACHMENT vol-4d826724 i-6058a509 xvdf attaching 2010-03-30T13:58:58+0000 

Note

The volume and instance must be in the same Availability Zone.

Note

Windows instances use either RedHat or Citrix paravirtual drivers. Regardless of which drivers you are using, you can attach up to 16 EBS volumes using the Amazon EC2 console. If your Windows instance is using Citrix drivers, you can attach up to a total of 25 EBS volumes using the EC2 CLI. To upgrade your Windows instance from RedHat to Citrix paravirtual drivers, see Upgrading Your PV Drivers on Your Windows AMI.

Note

If a volume has an AWS Marketplace product code:

  • The volume can only be attached to the root device of a stopped instance.

  • You must be subscribed to the AWS Marketplace code that is on the volume.

  • The configuration (instance type, operating system) of the instance must support that specific AWS Marketplace code. For example, you cannot take a volume from a Windows instance and attach it to a Linux instance.

  • AWS Marketplace product codes are copied from the volume to the instance.

For an overview of the AWS Marketplace, see https://aws.amazon.com/marketplace/help/200900000. For details on how to use the AWS Marketplace, see AWS Marketplace.

API

To attach an Amazon EBS volume to an instance, use AttachVolume. Construct the following request.

https://ec2.amazonaws.com/
?Action=AttachVolume
&VolumeId=volume-id
&InstanceId=instance-id
&Device=device
&AUTHPARAMS

The following is an example response.

<AttachVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/">
  <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> 
  <volumeId>vol-4d826724</volumeId>
  <instanceId>i-6058a509</instanceId>
  <device>/dev/sdh</device>
  <status>attaching</status>
  <attachTime>2008-05-07T11:51:50.000Z</attachTime>
</AttachVolumeResponse>

Note

The volume and instance must be in the same Availability Zone.

Note

Windows instances use either RedHat or Citrix paravirtual drivers. Regardless of which drivers you are using, you can attach up to 16 EBS volumes using the Amazon EC2 console. If your Windows instance is using Citrix drivers, you can attach up to a total of 25 EBS volumes using the EC2 CLI. To upgrade your Windows instance from RedHat to Citrix paravirtual drivers, see Upgrading Your PV Drivers on Your Windows AMI.

Note

If a volume has an AWS Marketplace product code:

  • The volume can only be attached to the root device of a stopped instance.

  • You must be subscribed to the AWS Marketplace code that is on the volume.

  • The configuration (instance type, operating system) of the instance must support that specific AWS Marketplace code. For example, you cannot take a volume from a Windows instance and attach it to a Linux instance.

  • AWS Marketplace product codes are copied from the volume to the instance.

For an overview of the AWS Marketplace, see https://aws.amazon.com/marketplace/help/200900000. For details on how to use the AWS Marketplace, see AWS Marketplace.