# How to mount EBS Volume on your EC2 Instance

## 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.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691760444586/c5a6abdb-003c-4ed1-99ec-569a3d19972e.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691760791871/afecb1dd-4282-403f-af72-be7459bf9601.png align="center")

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

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

```bash
df -h
```

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691761063487/190d25b9-4191-4eb4-8050-138b433e2acc.png align="center")

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.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691761248528/9c249145-571e-407a-9cfe-e1ed4088254f.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691761489399/0b7a607e-7bd0-42c2-a478-30912031349c.png align="center")

Your newly created volume should be shown now:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691761659423/12f2dab5-b51c-4e8a-b0da-9057aa0bb7eb.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691761839863/b8d922c4-9f06-4e23-9f44-528de898a3ba.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691761971775/9c58d5e9-8e9d-4c96-8603-35a621322bd8.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691762238856/f6d9420e-6e6a-4c9c-a247-aeea8c41fe1f.png align="center")

## 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:

```bash
lsblk
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691762397402/fed93045-720f-41a7-b36c-97b2a871ecd8.png align="center")

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:

```bash
sudo file -s /dev/xvdf
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691763810893/a5a02ee8-c684-45be-968d-0a6354081d54.png align="center")

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

```bash
sudo mkfs -t xfs /dev/xvdf
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691763915198/2639e467-6232-436b-85fe-7ffb7fa3ecf1.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691764046467/c00141b9-abf2-4ac1-a109-e365426091c0.png align="center")

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/`.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691764242517/b6a94a55-4b50-4fa9-b6fa-c002799b68eb.png align="center")

Now let's mount it using the `mount` command:

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

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691764397138/cbab0710-df9b-49ae-98dc-6d3c4102f4ec.png align="center")

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. ✨
