Amazon Elastic Compute Cloud
User Guide (API Version 2011-12-15)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

Attaching the Volume to an Instance

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

[Note]Note

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

The following table lists the devices that are technically possible to connect to, the ones reserved for root device and instance storage, and the ones we recommend for connection. For more information about the instance store, see Amazon EC2 Instance Storage. For information about the root device storage, see Root Device Storage.

Instance TypeTechnically Possible to Connect toReserved for Root and Instance StoreRecommended 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/sd[a] for root.

/dev/sd[b-e] for instance stores.

/dev/sd[f-p]

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

If you're having trouble using these, see the important note after this table.

Windows

xvd[a-p]

/dev/sda[1-2]

/dev/sd[b-e]

/dev/sda[1-2] for root.

xvd[a-e] for instance stores.

xvd[f-p]

After you have connected the device using the device names from the preceding table, the devices on your instance are mapped to either scsi drivers (sd[a-z]) or xvd drivers (xvd[a-p]), depending on the block device driver of your kernel. If the kernel has xvd drivers, then the devices will be mapped to xvd[a-p]. If the kernel does not have xvd drivers, then the devices will be mapped to sd[a-z][1-15].

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

The device mapping does not affect the way you connect to the devices.

Depending on the size of your instance, Amazon EC2 provides instance stores that uses the drives sd[b-e] (on Linux/UNIX) or xvd[a-e] (on Windows and CentOS HPC). Although it is technically possible to connect your Amazon EBS volumes to devices reserved for instance store, we highly recommend that you do not do so. The behavior can be unpredictable.

[Important]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].

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:\, etc. 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 Service in the Microsoft Windows Guide.

[Note]Note

You are limited to total of 12 EBS volume attachments on a Windows instance.

AWS Management Console

To attach an Amazon EBS volume

  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.

    The volume is attached to the instance.

Command Line Tools

To attach an Amazon EBS volume

  • Enter the following command.

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

    Amazon EC2 returns information that is similar to the following.

    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 

API

To attach an Amazon EBS volume

  • Construct the following Query request.

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

    Following is an example response.

    <AttachVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
      <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>