DEV Community

Cover image for Here’s a step-by-step beginner-friendly guide to attach and mount an EBS volume on an Ubuntu EC2 instance in AWS.
Oyewole Afuwape
Oyewole Afuwape

Posted on

Here’s a step-by-step beginner-friendly guide to attach and mount an EBS volume on an Ubuntu EC2 instance in AWS.

sign in to aws account using root user email

after signing in to my account, this is the landing page i got

Then i went to Ec2 to create my instance

After given my instance a name, went on to select my Operating system which is UBUNTU

After creating my EC2, then I went to create Volume as seen below

After i created my Volume, then I attached the volume to Ec2 instance, then connect to EC2 and set Volume

***SSH into Your EC2 Instance
ssh -i my-key.pem ubuntu@your-ec2-public-ip

List Block Devices to Confirm Attachment
lsblk

Format the New Volume with a Filesystem
sudo mkfs -t ext4 /dev/nvme1n1

***Create a Mount Point and Mount the Volume

Stop and Start the EC2

Wait for a while and Start the EC2

SSH Back

Check your data:
bash
copy Edit
sudo mount /dev/xvdf /data
cat /data/hello.txt

So to know the number of size used
df -h

Done!

I’ve successfully:

Created an EBS volume

Attached it to EC2

Formatted, mounted, and made it persistent

Top comments (0)