Note: Please go to docs.rightscale.com to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > Guides > Dashboard Users Guide > Clouds > AWS Regions > EBS Volumes > Actions > Attach an EBS Volume to an instance

Attach an EBS Volume to an instance

Overview

You can only attach an EBS Volume to a Server in the same availability zone, and to only one Server at a given time.  Therefore, if you want to automatically attach an EBS Volume to an instance when it is launched, you cannot use the "-any-" option for a Server's availability zone.  Be sure to specify the same zone as the volume.

Once you've created an EBS Volume, the next logical step is to attach it to an instance.  There are two ways you can attach an EBS Volume to an instance:

  • Attach now - Attach the EBS volume to a running instance
  • Attach on boot - The next time that the Server is launched, attach this particular EBS volume to the instance (at boot time).  For example, if the current running Server is relaunched, or terminated and launched, the volume that you're creating at this time will be preserved and attached to the new instance at boot time.  If this option is selected, the Volumes tab for the "Next" Server will reflect this change.  If you do not want this volume to be attached to the next Server that is launched, you will need to manually remove this volume association under the "Next" Server's Volumes tab.

Note: you cannot attach an EBS volume to a locked instance. It will fail.

Both attachment options are covered in this tutorial.

Important!  If you manually attach a volume to an instance, none of its attached volume(s) will be deleted when the Server is terminated.  You will need to manually terminate each volume once it's been detached from the instance. 

Steps

Attach an EBS Volume to a Running Instance

Go to Clouds -> AWS Region -> EBS Volumes and click the nickname of the EBS Volume that you want to attach to a running instance.  In order to attach a volume to a running instance, they must both be in the same availability zone.  Once a volume is created, you cannot change its availability zone.  Similarly, once an instance has been launched, you cannot change its availability zone.  Also, you cannot attach the same volume to multiple instances.  In order to attach the same volume to multiple instances, you must take a snapshot of the original volume and then create multiple volumes from the same snapshot.  A volume's status will be "available" if it is currently not attached to a running instance.  Otherwise, a volume's status will be "in-use."

Click the Attach now button.

Next, you will need to select which running instance the volume will be attached to, as well as the device location where the volume will be mounted. Choose an "/dev/sd" device name for Linux instances or an "xvd" device name for Microsoft Windows instances.
Note, if attaching more than 4 volumes, you will need to use the Override checkbox and specify a new, unused device name according to the operating system used (per above).

screen-AttachVolumeRunningInstance-v1.png

Click OK.

The EBS volume will become available for use when the volume's status is listed as "attached." 

screen-VolumeStatusAttached-v1.png

 

Verify the Volume was Attached

To verify that the volume was attached, you can SSH into the instance and run the following command:

cat /proc/partitions

You should notice that the volume was attached to the specified mount device (e.g. sdj).

major minor  #blocks  name
   8     1   10485760   sda1
   8    16   156352512  sdb
   8     3    917504    sda3
   8   144    1048576   sdj

This can also be achieved by the command, fdisk -l which is usually an easier way to verify the disk sizes.

Detach the Volume

To detach the volume, click the eraser action icon under the Actions column.  

Note:  If you terminate the Server, the attached volume(s) will not be deleted.  You will need to manually terminate each volume once it has been detached from the instance.

Attach an EBS Volume when an Instance is Launched

You can also configure an EBS Volume(s) to automatically be attached to a component when it is launched.  It's important that you specify that the new instance be launched in the same availability zone as the EBS Volume.  If the server's availability zone is set to "-any-" or to a different availability zone, you will not be able attach the volume to the instance.

NOTE: If there is an availability zone mismatch between a volume and an unlaunched server, you will receive the following warning message: "Volume and server are in different availability zones.  Force server to same zone as volume?"  If you click OK, the unlaunched server will be reconfigured to launch in the same availability zone as the attached volume.

EBS Volume can either be attached to an instance at the Server Level or at the Volume Level.

Volume Level 

Go to Clouds -> AWS Region -> EBS Volumes and click the nickname of the EBS Volume that you want to attach to an instance.  Click the Attach on boot time button.

  • Runnable - Select the server that the volume will be attached to.
  • Device - List of common device names. Choose an "/dev/sd" device name for Linux instances or an "xvd" device name for Windows instances. Select the "Override" option to specify a different value not in the list.

Click OK.

Server Level 

Go to a server's homepage and click the Volumes tab.  Click Attach Volume

  • Volume - Select the volume attachment.
  • Device name - List of common (Xen/Linux) device names to which the volume will be attached.
    Select the "Override" option to specify a different value not in the list.
    Choose a "/dev/sd" device name for Linux instances running on an EC2-patched kernel, or an "xvd" device name for Microsoft Windows instances.
    Note: For Xen native kernels (used by images such as Ubuntu (official) and Debian) the device is utilized by the kernel of the instance with "xvd" instead of "sd", e.g. attaching as /dev/sdk is accessible on the instance with /dev/xvdk.
  • Attachment options - See the "Overview" section above for detailed descriptions of each attachment option.
    • Attach now
    • Attach on boot

Click OK

Next steps (optional)

You can partition, format, and mount an EBS volume after attaching it to an instance at boot.

You must to post a comment.
Last modified
13:19, 24 Sep 2014

Tags

Classifications

This page has no classifications.

Announcements

None


© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.