Overview
AWS Elastic Block Store (EBS) offers high-performance block-level storage for EC2 instances.
In this post, I’ll describe a step-by-step process to attach and mount an EBS volume to an EC2 Linux instance running Ubuntu.
📚 This guide is at a beginner level difficulty. 📚
Creating an EBS volume and attaching it to an EC2 instance (on the AWS console)
- Open AWS Management Console and go to EC2 Dashboard
- Navigate to “Volumes” on the left panel.
- Click “Create Volume” and configure it with these settings.
- Select the Volume type (I’m using gp3 in this example)
- Set the volume size, IOPS and throughput.
- Set the availability zone the same as your EC2 instance.
- OPTIONAL: Encrypt the volume with a KMS key (I’m using the default EBS KMS key).

- Click “Create” and your volume will be ready in a bit to attach to the EC2 instance!
- Select the volume you just created (with a fancy name tag, no less), click “Actions” and select “Attach volume”

- In the “Attach volume” basic details section, select the EC2 instance you’re looking to attach the volume to, and click “Attach”.

- To confirm the volume got attached to the EC2 instance:
- Navigate to “Instances” on the left panel
- Select your EC2 instance
- Check the Storage tab.
Creating an EBS volume and attaching it to an EC2 instance (via Terraform! 🎉)
“Ah, Terraform”, he mused to himself while writing this example module. “I’ll sing your praise in some other post, perhaps.”
Infrastructure-as-code is great because it helps us maintain version-controlled and repeatable AWS infrastructure modules/patterns. Here’s an example of how you would create an EBS volume and attach it to an EC2 instance in a Terraform module. Here, we’re making use of variables to fill in required fields for these resources, so we can reuse this module in any future projects.
I know I’m using these fancy images to show the code so you can’t copy it from here –
That’s what you go to my ✨ GitHub ✨ for!

After that, you run these commands:

Mounting the EBS volume onto the EC2 instance
Use the following command to list attached block devices:
lsblk
Here we can see the volume attached to the instance (xvdbf):

Run the following commands.
(And again, you can get this from my GitHub)

Conclusion
In this guide, you learned how to attach an additional EBS volume to EC2 instance, all with zero downtime.
I’ll be posting more of these guides, going over a wide range of difficulty, so subscribe below! My newsletter sends out friendly emails when I make new posts.
Want to learn more about how I can assist you with your cloud and DevOps needs? Visit my homepage to get in touch and let’s find out how I can support your next project!