How to Attach EBS to EC2 instance?

How to Attach EBS to EC2 instance?

Steps to Attach EBS block to EC2 instance.

·

1 min read

Amazon Elastic Block Store (Amazon EBS) is an easy-to-use, scalable, high-performance block-storage service designed for Amazon Elastic Compute Cloud (Amazon EC2).

Note:- My EBS block name is xvdf, so be carefull when writing block name

  • To attached EBS, it should be in same Availability zone.
  • Now create an EBS and provide the size.
  • Now open EBS dashboard and attach it to the same availability zone instance.
  • Now SSH that instance and type lsblk and hit Enter, Now you can see all the storage of that instance.
  • But you can't access it now, to access it we have to format that EBS storage.
  • To format it, type this in your root directory sudo mkfs.ext4 /dev/xvdf
  • Now that EBS is formatted and ready to use, but not mounted.
  • To mount it Go to root directory using cd/ , now type mkdir /new_volume/
  • Now type mount /dev/xvdf /new_volume/ hit enter, and you are DONE!!
  • To check type mountpoint /new_volume

Screenshot (156).png

To de-attach that EBS from EC2

  • Go outside from that EBS directory and type umount /new_volume/
  • Now detach this EBS from AWS EBS Dashboard. Done!!