This content originally appeared on DEV Community and was authored by olatunji olamide
Cloud computing has changed how we manage storage and servers, making it easier to scale resources without worrying about physical hardware. One of the key components of Amazon Web Services (AWS) is Elastic Block Store (EBS), which provides reliable and persistent block storage for EC2 instances.
Think of EBS as an external hard drive for your cloud server—you can attach it, format it, mount it, and start using it to store data, databases, logs, or application files. Unlike the temporary root storage that comes with an EC2 instance, an EBS volume remains intact even if the instance is stopped or restarted.
In this guide, I’ll walk you through exactly how I attached and mounted an EBS volume to my Ubuntu EC2 instance, sharing the steps, commands, and best practices I used. By the end, you’ll have a clear roadmap to setting up persistent storage on AWS.
1. Prerequisites
Before diving in, list what’s needed:
- An AWS account
- An active EC2 instance running Ubuntu
- Basic knowledge of the AWS Management Console or CLI
- SSH access to your EC2 inv2. Step 1: Create an EBS Volume
2. Step 1: Create an EBS Volume
Explain how to create a new EBS volume from the AWS console:
- Go to EC2 Dashboard
→ Elastic Block Store → Volumes
- Click Create Volume
-Sieze:5gb, availability zone:must match your EC2 zone
- Click Create
3.Step 2: Attach the Volume to Your EC2 Instance
- Select the volume you just created
- Click Actions
→ Attach Volume
- Choose your EC2 instance from the list
- Note the device name (e.g., /dev/xvdf)
From here, the next steps would be:
Step 1: Log in to Your EC2 Instance
First, connect to your EC2 instance using SSH from your local computer:
ssh -i your-key.pem ubuntu@your-ec2-public-ip
your-key.pem = your private key file
your-ec2-public-ip = the public IP of your EC2 server
👉 This puts you inside your Ubuntu server, where you’ll run the next commands.
Step 2: Confirm the New EBS Volume is Attached
After creating and attaching the volume in the AWS console, check if the system sees it:
lsblk
Here:
xvda1 = root volume (where Ubuntu is installed)
xvdbb = the new EBS volume you just attached (unformatted, empty)
Step 3: Format the New Volume
sudo mkfs -t ext4 /dev/nvme1n1
Step 4: Create a Mount Point
sudo mkdir /data
*Step 5: mount it *
sudo mount /dev/nvme1n1/data
**
Create a new file,like writting something into it**
bash
echo "Hello from EBS!" | sudo tee /data/hello.txt
*Verify the file was created *
bash
cat /data/hello.txt
Stop and Start the EC2
Go back to EC2 console→stop the instance
Wait→start it again
check your data:
bash
copy Edit
sudo mount /dev/nvme1n1 /data
cat /data/hello.txt
Data is still there.because EBS is persistent
to know the number of gb used
df -h
📝 Conclusion
In this guide, we walked through the full process of adding and configuring an EBS volume on an Ubuntu EC2 instance. You learned how to:
- Create and attach a new EBS volume from the AWS Management Console
- Verify that the volume is visible inside your EC2 instance
- Format and mount it to a directory for use
By following these steps, you’ve expanded your instance’s storage and ensured that it’s properly configured for long-term use.
💡 Pro Tip: Regularly back up your data with EBS snapshots, and remember that volumes can be resized or moved across instances if your needs grow.
This content originally appeared on DEV Community and was authored by olatunji olamide

olatunji olamide | Sciencx (2025-08-26T23:27:52+00:00) “Step-by-Step Guide: Attaching and Mounting an EBS Volume on Ubuntu EC2”. Retrieved from https://www.scien.cx/2025/08/26/step-by-step-guide-attaching-and-mounting-an-ebs-volume-on-ubuntu-ec2/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.