Attach a previously created (existing) EBS Volume to an Instance.
Table of Contents
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 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.
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).
The EBS volume will become available for use when the volume's status is listed as "attached."
To verify that the volume was attached, you can SSH into the instance and run the following command:
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.
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.
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.
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.
Go to a server's homepage and click the Volumes tab. Click Attach Volume.
© 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.