Attach an EBS volume Created to EC2 Instance using AWS-CLI

Ayanchawla
Oct 17, 2020

EBS means elastic block storage. It is like a storage that can be used as pendrive for your ec2 instance. One volume is created when you launch an instance.

To Create an ebs volume, Click

Now, After you have created an ebs volume or maybe having number of volumes. To list the number of volumes present use command

aws ec2 describe-volumes

Now, Select the volume id and keep it with you.

Another thing you need is Instance with which you want to connect it.

Use the below command to check available instances.

aws ec2 describe-instances

Now, copy the instance id of the instances and keep it with you.

Finally, you have to select a name for device. You can give anything to it.

For example -

/dev/sdf, /dev/anything, etc.

It is just a string.

Command to attach an ebs volume to ec2 instance.

aws ec2 attach-volume --volume-id volumeId --instance-id instanceId  --device /dev/string

This will attach your ebs volume to Ec2 Instance.

Thank You for Reading

I would like to thanks Vimal Daga Sir. (https://www.linkedin.com/in/vimaldaga/)

Email — ayanchawlae@gmail.com

LinkedIn — https://www.linkedin.com/in/ayanchawlae/

--

--