Tuesday 6 June 2017

Creating an EBS volume and attaching it to an instance

Elastic Block Storage is a supporting storage service for EC2. Unlike S3 EBS is not independently accessible storage. An EBS volume (chunk of EBS) needs to be attached to an EC2 instance in order for it to become accessible or usable for storing data.

Creating an EBS volume:

Since EBS is not a standalone service we not find it listed within the AWS services dashboard. Go to EC2 within the AWS service dashboard and click on volume.


We can see that we have one volume which is in use since this is attached to a working AMI.


To create a new volume click on create volume. This opens up the below menu.


The default volume type selection is GP2 but there are a couple of more options available. On of them is Provisioned IOPS SSD. This one is interesting because this allows us to customize the IOPS for our volume in case of application specific requirements. We can specify the size of the volume, availability zone, encryption and we can also specify if we'd like to create a new volume from the snapshot of an existing volume. The availability zone selection is something to watch out for because the AMI to which we need to attach the volume should be in the same availability zone as our AMI.

To select a snapshot from which to create the volume just click within the snapshot box and select an option from one of the existing available options.


Click on create to create the volume. Click on refresh and our new volume will appear.


The volume state is available because it has not been attached to an AMI instance. To attach it to an instance select the volume go to actions and click on attach volume.

This will open up the below screen. Click within the box next to instance and a list of available instances will be displayed. Select the required instance.


After making the selection click on attach. Now we can see that the state of our EBS volume has been changed to in use. The device section will tell us the name with which the volume will be visible in the operating system.


To confirm that the EBS volume is available to the EC2 instance login to the instance and run fdisk -l command.

[root@ip-172-31-67-12 ~]# sudo fdisk -l | grep /dev
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/xvda: 8589 MB, 8589934592 bytes, 16777216 sectors
Disk /dev/xvdf: 2147 MB, 2147483648 bytes, 4194304 sectors

Our new disk is available as device /dev/xvdf of size 2GB.


Deleting an EBS volume:
To delete a volume it needs to be detached first. To do so select the volume and go to actions and click on detach volume.


After the volume has been detached it'll be back in available state. After this go to actions and click on delete volume.



1 comment:

Using capture groups in grep in Linux

Introduction Let me start by saying that this article isn't about capture groups in grep per se. What we are going to do here with gr...