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


Remember, you can only attach an EBS Volume to a server in the same availability zone.  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.

Attach an EBS Volume to a Running Instance

Go to Manage -> AWS -> 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 live 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's currently not attached to a running instance.  Otherwise, a volume's status will be "in-use."

Click the Attach button.

04-ebs_attach1.gif

 

Under your instance's Volumes tab you'll see the "Test" EBS Volume that you just attached to the running instance.

05-ebs_attach_listed.gif

To detach the volume, click the eraser button under Actions. 

 

 

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 Manage -> AWS -> EBS Volumes and click the nickname of the EBS Volume that you want to attach to an instance.  Click the Attach button at the top-right or under the Servers tab, click the "Add server for boot attachment" link.

11-ebs_attach_properties2.gif

  • Volume - Name of the volume attachment.
  • Server - Select the server that the volume will be attached to.  (Deployment / ServerName)
  • Device - List of common Linux device names.  Click the "Override" box to specify a different value.
  • Attachment Options - If an instance is running, you can immediately attach the volume ("Attach now"), as well as configure it to automatically attach the volume the next time the instance is launched.  If an instance is stopped, you can only "Attach on boot."
  • Additional Info - Relevant information about the server. 

Click OK.

 

 

Server Level 

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

09-ebs_attach_volume1.gif

 

10-ebs_attach_properties1.gif

  • Volume - Select the volume attachment
  • Server - Name of the server that the volume will be attached to.
  • Device - List of common Linux device names.  Click the "Override" box to specify a different value.
  • Attachment Options - If an instance is running, you can immediately attach the volume ("Attach now"), as well as configure it to automatically attach the volume the next time the instance is launched.  If an instance is stopped, you can only "Attach on boot."
  • Additional Info - Relevant information about the server. 

Click OK.

 

 

 

 

 

Tag page
Viewing 2 of 2 comments: view all
Before you attach a volume to the active instance, you have to run this command for the volume to be recognized. The great thing though, it only has to be run once!

Here is the command in quotes, "mkfs.xfs /dev/sdj".

The "mkfs.xfs" is the package to be run and the "dev/sdj" is the device of the volume.
---
Also, you need to attach a boot script to attach the volume every time the server is launched.

Here is an example: "
yum -y install xfsprogs
echo "/dev/sdj /home/webapps/[directory name]/[volume name]/ xfs noatime 0 0" >> /etc/fstab
mkdir -p /home/webapps/[directory name]/[volume name]
mount /home/webapps/[directory name]/[volume name]
"

"[direcoty name]" is the name of the directory that your instance is running under
"[volume name]" is the name of the directory that your volume will reside on.
---
Now, to make this volume to appear on the root directory or your domain, you can create a link in the shell using "ln -s" Using this you can define the directory that you want to link to point to and the link name inside the root directory of the domain. An example is listed bellow in quotes:
"
ls -n /home/webapps/[directory name]/[volume name]/ [new directoy]
"

"[direcoty name]" is the name of the directory that your instance is running under
"[volume name]" is the name of the directory that your volume will reside on.
"[new directory]" is the name of the directory that you want pointing to your volume.

If you run this link in the root directory of your domain, you will have a new directory that will be pointing to your volume.
Posted 17:21, 6 Oct 2008
Thanks for the helpful tips. I was just looking for this. However, I believe that you may have an extra "/" at the end of the path that you're putting into fstab. Shouldn't:
/home/webapps/[directory name]/[volume name]/
be:
/home/webapps/[directory name]/[volume name]

(I tried it the former way and got an error message)
Posted 13:44, 28 Oct 2008
Viewing 2 of 2 comments: view all
You must login to post a comment.