This content originally appeared on DEV Community and was authored by Oluwatunmise
Amazon Elastic Block Store (EBS) is a vital AWS service that provides persistent block storage volumes for EC2 instances. It enables you to store data that persists beyond the life of a single EC2 instance. In this guide, I’ll walk you through how I created, attached, formatted, mounted, and configured a new EBS volume on my Ubuntu EC2 instance.
Step 1: Create a New EBS Volume
From the AWS Console:
- I navigated to EC2 > Elastic Block Store > Volumes.
- Clicked Create Volume.
- Chose gp3 volume type, 5 GiB size, and selected the same Availability Zone as my EC2 instance (e.g.,
eu-west-1a
).
`
Why it matters: EBS volumes must be in the same AZ as your instance to be attachable.
Step 2: Attach the Volume to EC2 Instance
- After creating the volume, I selected it and chose Actions > Attach volume.
- I selected my EC2 instance and set the device name as /dev/xvdf.
Step 3: Connect to EC2 via SSH & Verify Volume
- I connected to my EC2 instance using SSH
Why it matters: This confirms the volume is visible to the OS.
Step 4: Format the Volume with ext4
Why: A filesystem must be applied before mounting. ext4
is a common Linux filesystem.
Step 5: Create Mount Point & Mount the Volume
The mount point is simply a directory on your Linux system (like /data) where the EBS volume’s storage will appear. Once mounted, any files you create or copy into /data are stored on that EBS volume, not on your instance’s root disk.
Step 6: Write a Test File
This proves the volume is writable and mounted correctly.
Step 7: Stop and Start EC2, Then Re-Mount
After stopping and starting the EC2 instance, I ran:
Conclusion: What I Learned
This exercise gave me a hands-on understanding of persistent storage in AWS. I learned how to:
- Provision and attach EBS volumes
- Format and mount them to an instance
And here’s an important note: since your root storage is an EBS volume, your data will still exist even if you stop the instance. When you start it again, it picks up right where you left off. The only time it gets deleted is if you chose the option Delete on termination.
Now I can confidently handle EBS in real-world scenarios.
If you’re new to EBS or EC2, I hope this post demystifies the process. Feel free to ask questions or share your experience in the comments!
This content originally appeared on DEV Community and was authored by Oluwatunmise