DEV Community

Cover image for Amazon Elastic Block Storage (EBS)
Ashutosh Mallick
Ashutosh Mallick

Posted on

Amazon Elastic Block Storage (EBS)

What is Instance storage?

  • Block-level storage volumes behave like physical hard drives.
  • An instance store provides temporary block-level storage for an Amazon EC2 instance.
  • An instance store is disk storage that is physically attached to the host computer for an EC2 instance, and therefore has the same lifespan as the instance. When the instance is terminated, you lose any data in the instance store.
  • Let's create two ec2 instances such as "Ticked-server" and "Unticked-server" based upon their delete on termination protection for instance storage is kept on or off. Image description Image description -But if we terminate instances we are likely to lose our instance volumes. Image description -Now let's terminate both the instances. After termination we can see that the volume for unticked server remains as such. Thus even on termination we can have our data secured if we untick the "delete on termination section". Image description Image description Amazon Elastic Block Store (EBS)
  • EBS is a block storage system used to store persistent data.
  • Amazon EBS is suitable for EC2 instances by providing highly available block level storage volumes.
  • It has three types of volume, i.e. General Purpose (SSD), Provisioned IOPS (SSD), and Magnetic. These three volume types differ in performance, characteristics, and cost.

EBS General Purpose (SSD)

  • This volume type is suitable for small and medium workloads like Root disk EC2 volumes, small and medium database workloads, frequently logs accessing workloads, etc. By default, SSD supports 3 IOPS (Input Output Operations per Second)/GB means 1 GB volume will give 3 IOPS, and 10 GB volume will give 30 IOPS. Its storage capacity of one volume ranges from 1 GB to 1 TB. The cost of one volume is $0.10 per GB for one month.

Provisioned IOPS (SSD)

  • This volume type is suitable for the most demanding I/O intensive, transactional workloads. By default, IOPS SSD supports 30 IOPS/GB, means 10GB volume will give 300 IOPS. Its storage capacity of one volume ranges from 10GB to 1TB. The cost of one volume is $0.125 per GB for one month for provisioned storage.

EBS Magnetic Volumes

  • It was formerly known as standard volumes. This volume type is suitable for ideal workloads like infrequently accessing data, i.e. data backups for recovery, logs storage. Its storage capacity of one volume ranges from 10GB to 1TB. The cost of one volume is $0.05 per GB for one month for provisioned storage and $0. 05 per million I/O requests.

Amazon EBS Benefits

  • Reliable and secure storage: Each of the EBS volume will automatically respond to its Availability Zone to protect from component failure.
  • Secure: Amazon’s flexible access control policies allows to specify who can access which EBS volumes.
  • Higher performance: Amazon EBS uses SSD technology to deliver data results with consistent I/O performance of application.
  • Easy data backup: Data backup can be saved by taking point-in-time snapshots of Amazon EBS volumes.

Adding an EBS volume to an instance

  • Let's create an instance "Test-1" and connect it via SSH using Xshell.
  • In Xshell type "sudo su" to login using root user.
  • Now to add extra volume to the instance, create an EBS volume of size say(15GB) and the volume should be created in the same region as that of the instance. Image description
  • Now attach the extra volume to your instance "Test-1". If you type "lsblk" on Xshell, you can see your 15GB vol. is addaed to your instance but it's not mounted yet. Image description -To mount the Extra-vol, first make a directory in the root then change path to that directory and mount your volume there.
  • In order to mount your EBS volume, first format the ddisk "india" using command "mkfs.ext4 /dev/xvdf". After formatting the disk mount your vol. using the command "mount /dev/xvdf /india".
  • You can list the volumes attached to your disk by running "df -h" in Xshell. Image description -Now create 100 files inside your folder using command "touch abc{1..100}
  • Now let's shutdown and restart the instance, we can observe that the particular volume that we mounted (15GB vol.) will be unmounted from the disk.
  • If we again mount the volume to our disk, we can't see our files listed. Hence, In order to make the changes permanent, we'll use Vi editor in fstab. It's for permanently mounting the volume to the disk.
  • To use the vi editor use the command "vi /etc/fstab". Enter i to insert. In the editor write " /dev/xvdf /india ext4 defaults 0 0". Then press esc and :wq to save the file.

  • now if we again restart our instance, we can see our 100 files listed in india folder as we made the changes permanent.

Image description

Discussion (0)