This series will discuss the three available storage options supported by EC2.
The first article of the series will discuss:
- * Introductory notions about Elastic Block Store(EBS)
- * Features of EBS
- * EBS volumes
- * Example showing the available operations related to EBS volumes
Amazon EBS offers a persistent storage that can be used with EC2 instances. The EBS volumes are network-attached and their persistence is not related to the life of the instance.
The EBS volumes can be used as an EC2 instance’s boot partition or like a block device attached to an EC2 instance. In the latter case, the volume behaves like a physical hard drive attached to the instance.
Because you might have different operating systems(Linux or Windows), you can format the volume with either ext3(for Linux) or NTFS(for Windows) filesystems.
There are three types of EBS volumes: General Purpose (SSD), Provisioned IOPS (SSD) and Magnetic. The difference between them is related to the performance characteristics with a direct relation to the price.
Before we go any further and explain the differences between all three volumes, we need to know what IOPS is. IOPS is input/output operations per second. EBS is measuring an IOPS as being a 16KB data chunk. Each EBS volume has an IOPS characteristic and that is the number of IOPS. For instance, let’s say that you have a volume of 1,000 IOPS. This means that you can transfer 1,000 * 16KB of data per second. This is roughly 16 MBs or 125Mbs bandwidth. You can have a variation of this in the sense that you could have 500 IOPS with 32KB of data as well.
Coming back to the volume types, let’s see the difference between them.
General Purpose volumes have a base of 3 IOPS/GB and the ability to burst to 3,000 IOPS for a finite period of time. So as you can see, the performance of General Purpose volumes is directly related to its size. What about the burst? Well, the volume performance is working on a credit mechanism. If you have a volume of 10G and for 1 second you don’t use any of the IOPS, then you have in your bucket additional 30 IOPS that you can use in the next second if you have a burst.
Each volume has an initial credit of 5,400,000 IOPS. As I said before, you are able to burst up to 3,000 IOPS. If you keep constantly like this, after 30 minutes you will have used all the IOPS.
So basically, the bigger the volume is the better performance you have and faster the balance refilling is.
Provisioned IOPS you basically select how many IOPS you want to have per volume with the condition that you cannot go above 4,000 IOPS.
Magnetic volumes are the cheapest and they can deliver only up to 100 IOPS with a burst of only a few hundred IOPS.
EBS is recommended when long-term persistence is required and when the data is changed often.
To summarize, the features of EBS are:
- * Persistent storage
- * General purpose
- * High availability
- * Provisioning using Provisioned IOPS
- * Variable size
So let’s see how you can add a new volume to a Linux and to a Windows EC2 instance, how you can make it usable and how you can delete it.
Currently I have two EC2 instances running: a Linux one and a Windows. Each EC2 instance has its default volume.
On the EC2 dashboard, from the ‘ELASTIC BLOCK STORE’ choose ‘Volumes’ and then click on ‘Create Volume’. A pop-up window will ask you for a few details regarding the new volume.
First we will create a volume for the Linux instance and then a volume for the Windows instance. Once you clicked on ‘Create’, then the new volume will show up next to the ones that were already there. I also added a suggestive name for each new volume so I would know what should go where:
After the volume was created, you have to attach it to the EC2 instance. From the list of volumes, select the volume that you would like to attach and from ‘Actions’ click on ‘Attach Volume’:
Once you do that, a pop-up window will ask for a few details and one of them will be to which instance you would like to attach the volume. If you click on ‘Instance’ field, then a list with all your instances will be shown and from there you can select your instance. In this case, the volume is attached to the Linux instance:
Once you click on ‘Attach’, the volume is attached to the EC2 instance.
Right now, you have a new volume added to the EC2 instance, but you cannot use it. You would have to configure the EC2 instance for this.
There is a specific procedure for Linux and Windows instances.
Let’s start with the Linux instance. Make sure that you are connected and from there confirm that the volume is attached by using ‘lsblk’:
[ec2-user@ip-172-31-29-28 ~]$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvda 202:0 0 8G 0 disk ââxvda1 202:1 0 8G 0 part / xvdf 202:80 0 10G 0 disk [ec2-user@ip-172-31-29-28 ~]$
Create a filesystem on the new device /dev/xvdf like this:
[ec2-user@ip-172-31-29-28 ~]$ sudo mkfs -t ext4 /dev/xvdf mke2fs 1.42.8 (20-Jun-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 655360 inodes, 2621440 blocks 131072 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2684354560 80 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done [ec2-user@ip-172-31-29-28 ~]$
Then create a mount point and mount the volume there:
[ec2-user@ip-172-31-29-28 ~]$ sudo mkdir /mnt/VOL_1 [ec2-user@ip-172-31-29-28 ~]$ sudo mount /dev/xvdf /mnt/VOL_1 [ec2-user@ip-172-31-29-28 ~]$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvda 202:0 0 8G 0 disk ââxvda1 202:1 0 8G 0 part / xvdf 202:80 0 10G 0 disk /mnt/VOL_1 [ec2-user@ip-172-31-29-28 ~]$
Right now, the volume can be used and you can do whatever you want with it. Just remember that in case of a reboot of the EC2 instance, you will have to mount the volume. You can mount the volume automatically by editing /etc/fstab adding this line:
/dev/xvdf /mnt/VOL_1 ext4 defaults,nofail 0 2
Now it’s time to do the same for Windows instance. Connect to the Windows instance using RDP and open ‘Computer Management’ from ‘Administrative Tools’. On the left menu, choose ‘Disk Management’ from ‘Storage’ and you will see the two disks attached:
Right now, the volume is attached, but it has to be made online and initialized. Then we need to assign a drive letter.
Select the new volume and ‘Action’ menu select ‘All Tasks’ and then ‘Online’. Do this one more time, but now select ‘Initialize Disk’ instead of ‘Online’ and follow the steps.
Next, right click on the new volume and choose ‘Change Drive Letter and Paths’. Follow the steps and assign drive letter ‘D’.
Once you do this, if you open ‘My PC’, you will notice a new drive:
I created a file in D: disk that will be helpful in the next part of series:
This is how you can detach the volume from EC2 instance. Select the volume from ‘Volumes’ menu and then from ‘Actions’ choose ‘Detach Volume’:
Keep in mind that before you detach the volume from an EC2 instance, that volume must be unmounted first.
This is how you can unmount on Linux:
[ec2-user@ip-172-31-29-28 ~]$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvda 202:0 0 8G 0 disk ââxvda1 202:1 0 8G 0 part / xvdf 202:80 0 10G 0 disk /mnt/VOL_1 [ec2-user@ip-172-31-29-28 ~]$ sudo umount -d /dev/xvdf [ec2-user@ip-172-31-29-28 ~]$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvda 202:0 0 8G 0 disk ââxvda1 202:1 0 8G 0 part / xvdf 202:80 0 10G 0 disk [ec2-user@ip-172-31-29-28 ~]$
And on Windows, repeat the same steps as with adding a new drive letter, but now remove the letter that is currently assigned to the volume.
In case you don’t need the volume anymore, you can delete it like this: select the volume from ‘Volumes’ menu and then from ‘Actions’ choose ‘Delete Volume’:
So there are the most common operations that you can perform with EBS volumes.
As a summary of this article, we learned how to:
- * Create a new volume
- * Attach the volume to the EC2 instance and then make it usable
- * Detach the volume
- * Delete the volume
The next part of the series will discuss the EBS snapshots.
Amazon Elastic Block Store (Amazon EBS) (link to http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AmazonEBS.html)
Amazon EBS Volumes(link to http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumes.html)