How to mount EBS Volume on your EC2 Instance

How to mount EBS Volume on your EC2 Instance

Quick learning about EBS and it's purpose with Ec2

The EC2 Instance

I have already created an EC2 Instance with the following specifications:

  • Ubuntu 22.04 LTS

  • AMI ID - ami-0f5ee92e2d63afc18

  • t2 micro - Free tier eligible

  • I also have created a Key Pair, which can be used to log in to the machine via SSH.

If you go to your instance's details > Storage, you should be able to see the currently attached volume.

As in my case, the default volume attached is 8 GiB.

You can also see this default volume, by using the following command:

df -h

So SSH into your machine, run this command and you should see the following:

Our default volume is present here!

Now we are going to create an EBS Volume and attach it to our Virtual Machine.

Create an EBS Instance

Scroll down on the left menu and select Volumes. Then we can click on Create volume to create an EBS Volume.

I am creating a 20 GiB volume, and giving it a tag test.

Your newly created volume should be shown now:

Let's attach this volume to our Virtual Machine by selecting it and clicking on Actions > Attach volume.

Select your machine from the drop-down, and click on Attach Volume.

You should see your newly created volume, attached to your machine:

Mount the volume to your machine

But if you run the df -h command again on your machine, you won't be able to see it. But why??

It's because the volume is not currently formatted, so it is blocked by the Linux system. You should see the volume in the blocked devices using this command:


There is a volume named as xvdf present here, let's check whether a file system is present on it or not using the following command:

sudo file -s /dev/xvdf

Currently, no file system is present, so let's create one using this command:

sudo mkfs -t xfs /dev/xvdf

Now the file system is created! You can see that using the sudo file -s /dev/xvdf command:

Now we can mount our volume on our system. But before doing that we should create a directory where the volume is going to be mounted using the mkdir command. If have created this directory /apps/volume/new-volume/.

Now let's mount it using the mount command:

sudo mount /dev/xvdf /apps/volume/new-volume

Now you can also see the volume using the df -h command:

And that's it for attaching an EBS Volume in your EC2 instance!

Hope this blog was informative, please like and comment to share your reviews. ✨