Create an EBS volume for the existing EC2 Machine in the same region.

 

Create an EBS volume for the existing EC2 Machine in the same region.

Step 1: 

Create a EBS Volume:

First login to your AWS web console and navigate to AWS EC2 dashboard location and go to Volume option.



Now, create a new ebs Volume, click on “Create Volume” Option and input the following details:

  • Volume Type: Standard or as you need
  • Size: As per requirement
  • Availability Zone: This should be in the same zone in which instance is running
  • Snapshot: Leave it if create fresh EBS




After filling all the details, just click on Yes, Create button. It will create a new EBS volume in a few
 sec ( depends on volume size ) and visible in your Volumes overview window with  available state.


Step 2:  Attach EBS Volume

In 1st step, we created an EBS volume, let’s attach it to instance of your choice. Follow below navigation option to find the options.




Select the ec2 instance from the instance as shown below and click on attach volume.




Step 3: Now, login to your ec2 instance and list the available disks using the following command.

lsblk



Step 4: Check if the volume has any data using the following command.

sudo file -s /dev/xvdf

If the above command output shows “/dev/xvdf: data“, it means your volume is empty.


Step 5: Format the volume to the ext4 filesystem using the following command.

sudo mkfs -t ext4 /dev/xvdf



Step 6: Create a directory of your choice to mount our new ext4 volume. I am using the name “newvolume“. You can name it something meaningful to you.

sudo mkdir /newvolume

Step 7: Mount the volume to “newvolume” directory using the following command.

sudo mount /dev/xvdf /newvolume/

Step 8: cd into newvolume directory and check the disk space to validate the volume mount.

cd /newvolume
df -h .

The above command should show the free space in the newvolume directory.




Comments