~ 6 min read

Create, attach, and detach EBS volumes

This academy article provides hands-on guidance on how you can create, attach, and detach EBS volumes to your EC2 instances on AWS.

Table of Contents

‍

Introduction

Creating an EBS Volume

Attaching an EBS volume to an EC2 instance

Detach and EBS Volume

Conclusion

Other Articles in this Series

‍

Introduction

‍

In our academy article - AWS EBS vs S3 vs EFS, we introduced the three storage services provided by AWS. After covering S3 in our last article, let’s deep dive into AWS EBS volumes in this one!

EBS (Amazon Elastic Block Store) is a type of storage from AWS which provides block level storage volumes. It is primarily used with EC2 instances in AWS and provides persistent data storage. The volumes can be scaled dynamically. We can also modify the IOPS capacity and change the volume type as well.

This article provides a walkthrough of how EBS volumes can be created, attached to and detached from an EC2 instance through the AWS console.

‍

Creating an EBS Volume

‍

  1. Log in to your AWS account via console (https://aws.amazon.com/console/)
  2. Once you have logged in, search for EC2 in the Search bar
  3. Once the EC2 console opens select Volumes on the left side navigation pane under the Elastic Block Store section

‍

Once the EC2 console opens select Volumes on the left side navigation pane under the Elastic Block Store section‍

  1. Click on Create Volume option

‍

Click on Create Volume option‍‍

  1. In the Volume Settings, provide the Volume Type. For more details about volume type refer to this AWS documentation (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volume-types.html )

‍

  1. Select the size of the volume as per the requirement.

There are certain constraints on sizing of EBS volumes. For details refer the following documentation (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/volume_constraints.html )

‍

  1. Select the IOPS for your EBS volume. IOPS is the number of I/O operations per second that the volume can support

‍

Select the IOPS for your EBS volume. IOPS is the number of I/O operations per second that the volume can support‍

  1. Throughput is the amount of data transferred from or to a volume. For EBS it is measured in MiB/s.

‍

Throughput is the amount of data transferred from or to a volume. For EBS it is measured in MiB/s.‍

  1. A volume can be attached to an EC2 Instance which is in the same AZ (Availability zone). So select the AZ in which your EC2 Instance is present and to which you want to attach the volume

‍

A volume can be attached to an EC2 Instance which is in the same AZ (Availability zone). So select the AZ in which your EC2 Instance is present and to which you want to attach the volume‍‍

  1. In Snapshot ID select the option Don’t create volume from a snapshot since in this walkthrough we want to create a fresh volume.

You can select the snapshot ID in case you want to create the volume from an existing snapshot.

 In Snapshot ID select the option Don't create volume from a snapshot since in this walkthrough we want to create a fresh volume.You can select the snapshot ID in case you want to create the volume from an existing snapshot.‍

  1. Encryption helps secure your data on EBS volumes. It uses the AWS KMS key to encrypt the data.

‍

Encryption helps secure your data on EBS volumes. It uses the AWS KMS key to encrypt the data.‍

  1. Create tags which will help to categorise your volumes, the team, or user it belongs etc.

‍

Create tags which will help to categorise your volumes, the team, or user it belongs etc.‍‍

  1. Select Create volume and your volume will be successfully created.

‍

Select Create volume and your volume will be successfully created.‍

Attaching an EBS Volume to an EC2 instance

‍

  1. Once the EBS volume is created select the EBS volume you want to attach to the EC2 Instance. The EBS volume should be in Available state.

‍

‍

  1. Click on the dropdown of Actions and select the option Attach Volume

‍

Click on the dropdown of Actions and select the option Attach Volume‍

  1. Once the Attach Volume window opens select the EC2 instance you want to attach the volume

‍

Once the Attach Volume window opens select the EC2 instance you want to attach the volume‍‍

  1. Select the Device Name which is the same device name used by the EC2 Instance selected in step 3 above

‍

Select the Device Name which is the same device name used by the EC2 Instance selected in step 3 above‍‍

  1. Select the Attach Volume option and the volume will be successfully attached. Once the volume is attached to an EC2 instance, the Volume Instance will be In-use.

Select the Attach Volume option and the volume will be successfully attached. Once the volume is attached to an EC2 instance, the Volume Instance will be In-use.## Detach an EBS Volume

‍

  1. In the Amazon EC2 console, choose Volumes in the navigation pane on the right side

In the Amazon EC2 console, choose Volumes in the navigation pane on the right side

  1. Once the Volumes page opens, select the volume you want to detach. An attached volume shows in-use state

‍

3. Click on the Actions drop-down and select the Detach volume option.

Once the Volumes page opens, select the volume you want to detach. An attached volume shows in-use state

  1. A pop-up will appear for confirmation, select the Detach button to detach the volume from the EC2 instance.

A pop-up will appear for confirmation, select the Detach button to detach the volume from the EC2 instance.5. Once you have successfully detached the volume you can again see that the volume is in Available state.

‍

Conclusion

‍

EBS volumes provide persistent storage and can be used just like physical hard drives for storing data. This article provides a step-by-step walkthrough of how you can create EBS volumes. It also covers how you can attach and detach volumes to your EC2 instances.

Follow along this article if you are looking to start out with EBS volumes and stay tuned for our next academy article where we will be covering a walkthrough for AWS EFS service.

‍

‍

  1. AWS EBS vs S3 vs EFS: Differences & Use Cases
  2. How to set up an S3 bucket on AWS
  3. How to set up EFS and use with multiple instances in different VPCs

‍

***

‍

This article is brought to you by Kloudle Academy, a free e-resource compilation, created and curated by Kloudle. Kloudle is a cloud security management platform that uses the power of automation and simplifies human requirements in cloud security. Receive alerts for Academy by subscribing here.

;