DEV Community

Cover image for Step-by-Step: How To Create and Attach EBS Volume.
Oluwatobiloba Oludare
Oluwatobiloba Oludare

Posted on

Step-by-Step: How To Create and Attach EBS Volume.

INTRODUCTION

When working with EC2 instances on AWS, you may often need additional storage beyond the default root volume. This is where Amazon Elastic Block Store (EBS) comes in—providing scalable, high-performance block storage for your EC2 instances. In this article, I’ll walk you through how to create an EBS volume, attach it to an EC2 instance, and properly configure it for use. Whether you are new to AWS or looking to sharpen your DevOps skills, this step-by-step guide will help you confidently manage EC2 storage the right way.

*Follow these steps: *

  1. Log in to AWS Management Console Go to: https://console.aws.amazon.com/

2. Navigate to EC2 Dashboard.

3. Create a New EBS Volume
In the EC2 Dashboard, scroll down to Elastic Block Store > Click Volumes.
Click Create Volume.
Choose:
Volume Type: (e.g., General Purpose SSD gp3)
Size: (e.g., 4 GiB or more)
Availability Zone: Must match your EC2 instance's AZ (e.g., us-east-1a)
Click Create Volume

4. Attach Volume to EC2
After creation, select the volume.

Click Actions > Attach Volume.

Select the EC2 instance from the dropdown.

You can select /dev/xvdbb and click Attach.

*5. Connect to EC2 *

SSH into your EC2 instance using this command: ssh -i your-key.pem ec2-user@your-ec2-public-ip

*6. Format *
Run these commands: sudo mkfs -t ext4 /dev/xvdbb

7. Create a mount point using this command sudo mkdir /mnt/my-ebs

8. Mount the volume

sudo mount /dev/xvdbb /mnt/my-ebs

Congratulation!

Challenge I Faced
One of the initial challenges I encountered was making sure the EBS volume was created in the same Availability Zone as my EC2 instance.

At first, I mistakenly created the volume in a different Availability Zone, which made it impossible to attach it to my instance. This taught me the importance of always double-checking the Availability Zone when creating resources that need to work together in AWS.

CONCLUSION

By following the steps in this article, you’ve successfully created and attached an EBS volume to your EC2 instance. This setup allows for better data management, flexibility, and scalability in your cloud infrastructure. As you continue exploring AWS services, understanding how to leverage EBS effectively will be essential for managing storage needs in real-world projects.

Stay curious, and keep building!

Top comments (0)