DEV Community

Cover image for Adding an EBS volume to a running AWS EC2 Instance

Adding an EBS volume to a running AWS EC2 Instance

When creating an EC2 instance on AWS, you are given the option to select the size of your storage. However you may run into a scenario where you need more storage than what you have provisioned . In that case. you can either increase the size of the storage or attach an extra EBS volume to your instance . This short post is about showing how to add an extra volume to an EC2 instance.

I assume that you already know how to create a EBS volume.

Spin out your instance and attach the new volume created by following the instructions below.

  • Select the new volume
  • Under the "Action" tab select "attach volume"
  • Select the EC2 instance you created
  • Under " Device name , keep /dev/sdf
    (as best practice in linux, /dev/sda1 is for root volume and /dev/sd(f-p) for data volumes )

  • Select "Attach volume"

Image description

After attaching the volume, there are few extra steps to do in order to make sure that the volume is accessible.

SSH into your EC2 and run the command below

 df -f
Enter fullscreen mode Exit fullscreen mode

you will only see the root volume and not the newly attached volume.

Image description

To "SEE" the newly mounted volume, run the command below

lsblk
Enter fullscreen mode Exit fullscreen mode

Now you will see the newly mounted volume along with its mount point.

Image description

The next step will be to mount the new volume. Run the command below

 sudo mkfs -t xfs /dev/xvdf
 sudo mkdir  /data 
 sudo mount /dev/xvdf /data
Enter fullscreen mode Exit fullscreen mode

After that when we run the "df -h" command , you we should be able to see the new volume along the with the root volume

Image description

Hope you like it.
Site Web :www.asksouley.com
Twitter :@asksouley

Top comments (0)