“One of the most powerful features of Amazon EC2 is the ability to attach storage volumes to instances. EBS volume acts like any other disk that one might install in a physical server, and they can be used for many purposes: file storage, databases, or even swap space.”

AWS EBS Volumes: Flexible Storage Solutions

Amazon Elastic Block Store (EBS) volumes play a pivotal role in AWS storage. An EBS volume is a durable block-level storage device that can be attached to Amazon EC2 instances. It provides persistent storage that is decoupled from the EC2 instance’s lifecycle, allowing data retention even after instances are terminated. AWS EBS offers different volume types, each designed to cater to specific performance and cost needs. These volume types include General Purpose (SSD), Provisioned IOPS (SSD), Cold HDD, Throughput Optimized HDD, and more. By selecting the appropriate EBS volume type, users can optimize storage performance, durability, and pricing to suit their specific application requirements.

To create an Amazon Elastic Block Store (EBS) volume, follow these easy steps. First, navigate to the AWS Management Console and access the EC2 dashboard. From there, click on “Volumes” in the left-hand menu. Next, click the “Create Volume” button, where you can specify the volume size, type (consider various EBS volume types like General Purpose, Provisioned IOPS, or Cold HDD), and availability zone. After configuring your preferences, click “Create Volume.” Once the volume is created, you can attach it to an EC2 instance. Amazon EBS volumes are a crucial component of AWS infrastructure, providing scalable and durable block storage for your cloud resources, and understanding their types is essential for optimizing performance and cost-efficiency.

What is AWS EBS Volume?

An AWS EBS volume is storage that persists independently from an instance’s life cycle. An AWS EBS volume does not have any single point of failure, and with its flexible volumes, you can launch as many instances using the same volume as you need.

Amazon Elastic Block Store (EBS) provides block-level storage volumes for use with EC2 instances in Amazon Web Services. EBS allows users to connect virtual devices (volumes) to a network that is available only when your system or instance is running. This makes it possible to configure systems or servers, save data on them reliably, and keep the configuration even if the server has been stopped for any reason.

You can attach an EBS volume to one EC2 instance. Then you can use it as a normal hard drive or partition. You can format the file system on it, store data on it, and delete volumes when they are no longer needed.

EBS volume is designed to provide very high throughput and IOPS (Input/output operations per second) which scales automatically depending on the size of your volume.

Amazon EBS volume allows users to snapshot their volume. A Snapshot contains all blocks currently in use by a particular volume at a given point in time and saves that information into Amazon S3 storage which you can later use to restore the volume’s state and contents during your maintenance window

Build Your Career as a
AWS Solution Architect

AWS Solutions Architect Associate

Boost your earning potential with AWS expertise. Explore our certified AWS Courses for a high-paying career

Let’s create an EBS volume

EBS Volume

  • You will be taken to the EC2 Dashboard by selecting EC2 from Compute.

ebs volume types

  • Click on Instances on the left side of the dashboard

ebs types

  • On the next screen, click the launch instances option

ebs performance

  • Select the Amazon Machine Image (AMI) option.
  • Instances in the cloud are based on Amazon Machine Images (AMIs), which contain all the information necessary for their launch.
  • Amazon Linux 2 AMI is eligible for the Free tier and you will not incur any charges on your AWS account if you choose this.

ec2 volume

  • Now we need to select the instance type. The default selection is t2.micro, and since that’s within the free tier, we will move forward with it.

ebs volume

  • Click on Next: Configure Instance Details
  • Increase the number of instances to 2

types of ebs

  • Click on Next: Add Storage, and all the settings will stay the same
  • Click on Next: Add Tags without adding storage.

EBS Volume

  • As shown in the following picture, we will name it

ebs volume types

  • Click on Next: Configure Security group
  • Create a new Security Group name as EC2-SG  keep the description as same and then click on Add rule, from the list select HTTP and select the sources as Anywhere for both SSH and HTTP
  • Click on Review and Launch

ebs types

  • After Reviewing click on Launch 
  • During the next step, you will be asked whether to create a new key pair or use a previously created key pair
  • Here we will create a new key pair. Click on Create a new key pair and give it a name as EC2-key and then click on Download key pair
  • After clicking on the Download key pair click on Launch instances

ebs performance

Note: Please remember to download the key pair before launching the instance. Once the instance is running you will not be able to download the key pair.

  • Click on View Instances

ec2 volume

  • You will now see that instances are in a pending state, but wait a few seconds and they will appear to be running

ebs volumes

  • Click Volumes in the left-hand panel. Because you’ve created 2 EC2 instances, you’ll find 2 root volumes over there, each attached to an instance. All are of 8GB

types of ebs

EBS Volume

  • Click on Create volume, which will then be attached to a specific instance. Verify that the volume you are creating is in the same Availability Zone (AZ) as the instances (go to the EC2 instances you’ve launched and check)
  •  Leave the volume type as General Purpose SSD and enter the size as 10GB (demo purpose)

ebs volume types

  • Add tags and give it a name of your choice. {So this is going to be the data volume where we will store data} 
  • Click on Create volume
  • Since there is no EC2 instance attached to the volume, it will display as Available mode.

ebs types

  • Select the volume, click Actions, and then select Attach Volume
  • When it asks you to select an instance, just pick the instance of your choice [but remember, if you created the volume in a different AZ, then you won’t be able to choose any instance}. 
  • When you select the instance and click Attach, the volume will be shown as in-use

 ebs performance

 ec2 volume

  • Once again, select Instance-1 from Instances and click Connect

ebs volumes

  • Your Amazon login will have the username ec2-user and will display the instance-id and IP address of the instance
  • Click on Connect

types of ebs

  • The first thing you will see after you log in is a black window with your username as ec2-user.

EBS Volume

  • Now we’ll use some Linux commands here and you should enter the commands carefully because Linux is case-sensitive.
  • Type “lsblk“(press enter) and you will get “xvdf” as the disk name.

ebs volume types

  • To mount it, we must first access it
  • Type sudo file -s /dev/xvdf (press enter)
  • This output will give us data that means there is no file system on the device and we have to create one. So, for this, we will use another command
  • Type sudo mkfs -t ext4 /dev/xvdf (press enter) (ext4 is for formatting)

ebs performance

  • Type sudo mkdir /data (press enter)
  • “data folder is created” and it will show as “xvdf/data”
  • Now to mount it
  • Type sudo mount /dev/xvdf /data (press enter) 
  • To confirm type “lsblk” and press enter and you will see “xvdf” is mounted to the data folder.

ec2 volume

  • Go to data folder by typing “cd /data
  • Now we will make a file
  • Type sudo touch Hello.txt (press enter)
  • To confirm it is created or not type “sudo ls

EBS Volume

  • Now to edit that file type we will use VI editor here
  • Type sudo vi Hello.txt (press enter)
  • Editing mode is enabled now, Press “i” for inserting the command and {move your cursor below the UUID path given there}
  • Type “hello world” and press escape (ESc key) and then type ” :w ” (press enter) and then type ” :q! ” (press enter and you will be out of the editor)
  • To check if hello world is there
  • Type cat Hello.txt (press enter) output will show “hello world” 

ec2 volume

  • Now we will add entry and mount our file to the specified mount point
  • Type sudo vi  /etc/fstab
  • Again press “i” for insert mode and {move your cursor below the UUID path given there}
  • Type /dev/xvdf /data ext4 defaults,nofail  0  2 {remember there is double space after nofail and also after 0} (press enter)
  • Press escape (ESc Key) and then type ” :w ” (press enter) then type ” :q! ” (press enter and you will be out of the editor)

ebs volumes

  • So to check if mounted or not  Type cat /etc/fstab (press enter) output will show it is mounted

ebs performance

  • To verify the file system is formatted or not
  • Type sudo file -s /dev/xvdf
  • Now to unmount the data firstly come out of the folder by using cd ../
  • Type sudo umount /data (remember the command is “umount” not unmount)
  • To confirm type “lsblk” and you will see that it is unmounted
  • Now we will test our fstab file
  • Type sudo mount -a (press enter)
  • To confirm type “lsblk” and press enter and the output will show that data has become the specified mount point

Congratulations!! You have created and Formated an EBS volume. See you in the next Lab.

AWS seems interesting to you. Explore our free resources, which will land you a job in your dream company

  • A blog over AWS IAM interview questions.
  • A dictionary for AWS S3 interview questions.
  • An article on AWS EC2 interview questions.
  • An introductory guide for data ingestion in AWS.
  • Program for AWS live projects training.

Conclusion:

After reading this blog post, you should now know how to create an EBS volume and be able to do so in the AWS console. We also provided a step-by-step guide for accomplishing this task with Terraform.

If anything is unclear or if you want more information on any of these topics, please don’t hesitate to reach out! Our team is always happy to help our customers succeed. In addition, we offer AWS certification courses and Blogs designed specifically for AWS cloud practitioner certification courses.