Thursday, 18 August 2011

Amazon EBS volume and adding new EBS volume to Amazon EC2 instance

Amazon Elastic Block Store (EBS) is a block level storage volume that we can use with Amazon EC2 instances. Amazon allows creating 1GB to 1 TB size EBS volume and it can be mounted/attached to an EC2 instance. A volume can only be attached to one instance at a time, but we can attach multiple EBS volumes to an EC2 instance. We can also detach an EBS volume from an EC2 instance and same EBS volume can be attached to another EC2 instance. Like EC2 instance EBS volumes are also placed in a specific availability zone, and an EBS volume can only be attached to instances that are in the same availability zone. Once we attach an EBS volume in an instance, it will appear as a mounted device in that instance similar to any hard drive or other block device. EBS volumes are suitable for applications that require storage for database, file system, or access to raw block level storage. We can also take point-in-time snapshots of EBS volumes, which are stored to Amazon S3. Amazon says that EBS volumes are designed to be highly available and reliable, and its data is replicated across multiple servers in an availability zone to prevent the loss of data from the failure of any single component.

We can also boot an EC2 instance from an EBS volume, for that we have to use one of the AMIs Amazon has prepared for this purpose. Currently Amazon provides Windows and Fedora Linux EBS AMIs. If we booted an EC2 instance with EBS volume, a new EBS volume will appear in the Volume pane in the AWS management console.
I have just booted a Windows 2008 EC2 instance with EBS volume; in the following screenshot we can see the Root Device as ebs:

Let’s see the disk management of the instance and we can see the EBS volume in the instance:

Also if we see the AWS management console, we can see the EBS volume of size 30GB that is attached to our instance.

We also have to pay for this volume in addition to the instance cost. The main advantage of booting an instance from EBS volume is that the instance can be stopped. Stopping an EC2 instance will not delete the EBS volume. The volume will be there in our account. Stopping an instance with EBS volume will release the instance’s computing resources; but we will be charged for the EBS volume storage.

Now I am going to add a new EBS volume of size 25GB as a partition in my Windows 2008 instance.

Go to Volumes link in AWS management console 

Click on Create Volume button

We are in Create Volume screen, here we have to enter the size of the volume, availability zone (remember to select the same availability zone as our EC2 instance) and Snapshot, as we are going to create a fresh volume so I have selected No Snapshot. The Snapshot list allows us to create the new volume based on a snapshot created by us or by other user’s shared snapshots. Click on Create button to create the new volume.

Our EBS volume is getting created; we can see the status as creating. It takes few seconds to have our volume ready to use.

Now our volume is ready to use as it is showing status available. Now we can attach it to some EC2 instance.

Select the volume and right click and click on Attach Volume.

We have to select the instance to which we want to attach this volume. Also enter the device name for this volume. Click on Attach button.

Now if we go to disk management of our Windows 2008 EC2 instance, we can see the new disk Disk1.

Click on the disk and click on Online to make this disk online.

Click on Initialize Disk to start disk initialization process.

 Select the disk Disk1, select partition style as per the requirement. Here I am selecting MBR. Click on OK.

Select the disk Disk1, select partition style as per the requirement. Here I am selecting MBR. Click on OK.

Now right click on the disk and click on New Simple Volume.

Click on Next on New Simple Volume Wizard.

Select the volume size and click Next.

Select the drive letter for the new disk and click Next.

Select the information required for formatting the disk and click Next.

Click Finish to end the New Simple Volume wizard and our new 25GB partition is ready to use.

If our work is done with this volume, we can detach that volume from the EC2 instance. For that select the volume in AWS management console and click on Detach Volume button. We will get a confirmation message and we have to confirm that we are detaching the volume.

জয় আই অসম,
প্রণব শর্মা