AWS Elastic Block Storage (EBS)

ANUPREET DUBE
Hands on for some  Technical Integrations
3 min readMar 23, 2021

--

Attaching Block Storage (EBS) to an Instance (EC2) on AWS Cloud via AWS CLI

🔹TASK AGENDA

Attaching Block Storage Device from a Cloud (EBS Service of AWS) to an Operating System on the Cloud (Instance → EC2 Service of AWS)

🔸Procedure

  1. Create a key pair
  2. Create a security group
  3. Launch an instance using the above
    created key pair and security group.
  4. Create an EBS volume of 1 GB.
  5. Attach the EBS Volume to the EC2 Instance

🔅STEPS🔅

1️⃣ Create a key pair

(Install and configure AWS CLI in windows CMD Prior running the below commands)

aws ec2 create-key-pair --key-name <name.of.key>

Now, check in the EC2 Dashboard → Network and security → Key Pairs :

Our new key will be created !

2️⃣ Create a Security Group

This step will create a Firewall which will be attached to instance to control and regulate Egress and Ingress Traffic.

aws ec2 create-security-group --group-name <name.of.sec.grp> --description "SG for EBS EC2 --vpc-id <VPC.ID>

This will create a Security group in the specified VPC.

Now, check in the EC2 Dashboard → Network and security → Security Groups :

A new Security Group will be created !

3️⃣ Launch an EC2 Instance

To launch an Operating System on the Top of Cloud using CLI :

aws ec2 run-instances --image-id <AMI-ID> --instance-type t2.micro --count <no. of instances to be launched> --subnet-id <SubnetID> --security-group-ids <ID of security Group> --key-name <name of key>

The parameters passed in this step are:

  • Image ID — which Base Image is to be used to launch the instance
  • Instance Type — To specify CPU, RAM, etc..
  • Count — to specify number of similar instances to be launched
  • Subnet ID — to specify the subnet in which Instance is to be launched
  • Security group — Created in Step-2
  • Key-Pair — Created in Step-1

Now, check in the EC2 Dashboard →Instances → Instances :

The New Instance will be created !

4️⃣ Create an EBS of 1 GB

This is to create a Block Storage of 1 GB for the Instance.

create-volume --availability-zone ap-south-1 --volume-type gp2 --size 1

The parameters passed in this step are:

  • Availability Zone— The AZ of EBS and EC2 to which it will be mounted must be Same.
  • Volume — gp2 : for specifying EBS type
  • Size — 1 GB

Now, check in the EC2 Dashboard → Elastic Block Storage→ Volumes :

A new EBS for 1 GB will be created !

5️⃣ Attaching EBS to EC2

This is to Mount the EBS Volume to the

aws ec2 attach-volume --instance-id <EC2 Instance ID> --volume-id <EBS ID> --device /dev/sdf

The parameters passed in this step are:

  • Instance ID — ID of EC2 instance to which the EBS Volume is to be attached
  • Volume ID — ID of EBS
  • Device — The mount path of EC2

Now, check in the EC2 Dashboard →Elastic Block Storage→ Volumes :

EBS is Mounted to the Mount Path of EC2

The EBS is attached to EC2. Also Check in Instances : the EC2 is attached to EBS!

📌 This Research Work is the 3rd Task for my Training program at Arth — The School Of Technologies. I am Grateful to my Mentor Vimal Daga Sir for his guidance and support which enabled me to reach to the completion of this research Article

Suggestions for improvements are always welcomed.. 😊

--

--