Beginners Guide on how to Attach and Mount an EBS volume on Ubuntu EC2 Instance in AWS

When working with Amazon EC2 instances, storage is a crucial part of your setup. While the root volume (the one that comes with your instance) is enough for basic usage, you’ll often need additional storage for applications, logs, or databases. That’s …


This content originally appeared on DEV Community and was authored by Morris Ndeobi

When working with Amazon EC2 instances, storage is a crucial part of your setup. While the root volume (the one that comes with your instance) is enough for basic usage, you’ll often need additional storage for applications, logs, or databases. That’s where Amazon Elastic Block Store (EBS) volumes come in.

In this guide, i will show you step-by-step work around on how to attach and mount an EBS volume to an Ubuntu EC2 instance. This tutorial is beginner-friendly, so even if you’re just starting with AWS, you’ll be able to follow along.

🛠 Prerequisites

Before we start, make sure you have:

An AWS account.

A running Ubuntu EC2 instance.

SSH access to your EC2 instance, via Gitbash or command prompt.

Step 1:
Create an EBS Volume

Open the AWS Management Console → go to EC2.

In the left menu, click Volumes under Elastic Block Store.

Click Create volume.

Volume type: Choose gp3 (general-purpose SSD).

Size: For this demo, select 5 GiB.

Availability Zone: Must be the same AZ as your EC2 instance (e.g., us-east-1a).

✅ You now have an unattached EBS volume.

Step 2:

Attach the EBS Volume to the EC2 Instance

Go back to the Volumes page.

Select your newly created volume.

Click Actions → Attach volume.

Select your running EC2 instance.

For device name, enter /dev/xvdf (or leave the default /dev/sdf).

Click Attach.

✅ The volume is now attached to your instance, but not yet usable.

Step 3:
Connect to Your EC2 Instance

Open your terminal and connect to your instance via SSH:

ssh -i your-key.pem ubuntu@

Step 4: Verify the Attached Volume

Run this command to list block devices:

lsblk

Step 5:
Format the Volume (First-Time Use)

If this is a new volume, you need to create a filesystem on it:

sudo mkfs -t ext4 /dev/xvdf

Step 6: Create a Mount Point

Create a directory where you’ll mount the volume:

sudo mkdir /data

Step 7:

Mount the EBS Volume

Now, mount the volume to the directory:

sudo mount /dev/nvme1n1 /data

Check if it worked:

df -h

You should see /dev/nvme1n1 mounted at /data. 🎉

Step 8:
Enter a text file.

bash
echo "Hello from NDEOBI!" |sudo tee/data/hello.txt

now verify that the text file was created
bash
cat /data/hello.txt

Step 9:
Now you have to stop and restart the instance that was created. and then SSH with the command
ssh -i /c/Users/username/Downloads/yourkeynote.pem ubuntu@ ip add



check your data
bash
copy edit
sudo mount /dev/nvme1n1 /data
cat /data/hello.txt

Save and exit.

✅ Conclusion

You’ve just learned how to:

Create an EBS volume.

Attach it to an Ubuntu EC2 instance.

Format and mount it.

important notice: The device name when choosing your volume device name will change from /xvdbb to nvme1n1. you should continue with this device name in your ssh.

With these steps, you can easily scale your EC2 storage as your needs grow.

👉 Pro tip: Always double-check the availability zone when creating an EBS volume, otherwise you won’t be able to attach it to your instance.


This content originally appeared on DEV Community and was authored by Morris Ndeobi


Print Share Comment Cite Upload Translate Updates
APA

Morris Ndeobi | Sciencx (2025-08-25T13:42:31+00:00) Beginners Guide on how to Attach and Mount an EBS volume on Ubuntu EC2 Instance in AWS. Retrieved from https://www.scien.cx/2025/08/25/beginners-guide-on-how-to-attach-and-mount-an-ebs-volume-on-ubuntu-ec2-instance-in-aws/

MLA
" » Beginners Guide on how to Attach and Mount an EBS volume on Ubuntu EC2 Instance in AWS." Morris Ndeobi | Sciencx - Monday August 25, 2025, https://www.scien.cx/2025/08/25/beginners-guide-on-how-to-attach-and-mount-an-ebs-volume-on-ubuntu-ec2-instance-in-aws/
HARVARD
Morris Ndeobi | Sciencx Monday August 25, 2025 » Beginners Guide on how to Attach and Mount an EBS volume on Ubuntu EC2 Instance in AWS., viewed ,<https://www.scien.cx/2025/08/25/beginners-guide-on-how-to-attach-and-mount-an-ebs-volume-on-ubuntu-ec2-instance-in-aws/>
VANCOUVER
Morris Ndeobi | Sciencx - » Beginners Guide on how to Attach and Mount an EBS volume on Ubuntu EC2 Instance in AWS. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/08/25/beginners-guide-on-how-to-attach-and-mount-an-ebs-volume-on-ubuntu-ec2-instance-in-aws/
CHICAGO
" » Beginners Guide on how to Attach and Mount an EBS volume on Ubuntu EC2 Instance in AWS." Morris Ndeobi | Sciencx - Accessed . https://www.scien.cx/2025/08/25/beginners-guide-on-how-to-attach-and-mount-an-ebs-volume-on-ubuntu-ec2-instance-in-aws/
IEEE
" » Beginners Guide on how to Attach and Mount an EBS volume on Ubuntu EC2 Instance in AWS." Morris Ndeobi | Sciencx [Online]. Available: https://www.scien.cx/2025/08/25/beginners-guide-on-how-to-attach-and-mount-an-ebs-volume-on-ubuntu-ec2-instance-in-aws/. [Accessed: ]
rf:citation
» Beginners Guide on how to Attach and Mount an EBS volume on Ubuntu EC2 Instance in AWS | Morris Ndeobi | Sciencx | https://www.scien.cx/2025/08/25/beginners-guide-on-how-to-attach-and-mount-an-ebs-volume-on-ubuntu-ec2-instance-in-aws/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.