DEV Community

Cover image for Creating and Attaching an Amazon EBS Volume to an EC2 Instance on AWS
Kolarinde Awopetutimileyin
Kolarinde Awopetutimileyin

Posted on

Creating and Attaching an Amazon EBS Volume to an EC2 Instance on AWS

Step 1 — Open the EC2 Console


From the AWS EC2 dashboard, click Launch instance to begin creating a new virtual server that will later have an EBS volume attached.

Step 2 — Name the Instance and Choose an AMI


On the Launch an instance page, name the instance (e.g. "EBS-SERVER") and select an Amazon Machine Image — in this case, Amazon Linux 2023.

Step 3 — Configure Key Pair and Network Settings

 Select or create a key pair (e.g. "ebs-key") for SSH access. Under Network settings, confirm the VPC and subnet, enable auto-assign public IP, and allow SSH traffic from Anywhere (or a restricted IP range) via the security group.

Step 4 — Review Storage and Launch the Instance


In Configure storage, keep the default root volume (8 GiB, gp3). Leave file systems set to None (since the EBS volume will be attached separately), review the launch summary, and click Launch instance.

Step 5 — Confirm the Instance Is Running


On the Instances page, confirm the new instance ("EBS-SERVER") shows a Running state with status checks passed.

Step 6 — Navigate to EBS Volumes


Under Elastic Block Store > Volumes, view existing volumes and click Create volume to provision a new EBS disk.

Step 7 — Configure the New Volume


Set the volume type (General Purpose SSD gp3), size (e.g. 4 GiB), IOPS, and throughput. Choose the same Availability Zone as your EC2 instance (critical — EBS volumes can only attach to instances in the same AZ), then create the volume.

Step 8 — Attach the Volume via Actions Menu


Back in the Volumes list, select the new volume's checkbox, click Actions, and choose Attach volume to link it to the running instance.

Step 9 — Complete Attachment Details


On the Attach volume page, confirm the Volume ID and Availability Zone match, select the target instance ("EBS-SERVER"), specify a device name (e.g. /dev/sdb), and click Attach volume.

Step 10 — Connect to the Instance


From the Instances page, select "EBS-SERVER" and click Connect to proceed to SSH connection setup.

Step 11 — Locate the Private Key


In your local editor (e.g. VS Code), open the downloaded private key file ("EBS-KEY.pem") to confirm it's accessible and ready to use for the SSH connection.

Step 12 — Copy and Run the SSH Command


Under the SSH client tab, follow the steps to set correct key permissions (chmod 400 "EBS-KEY.pem") and copy the SSH command (e.g. ssh -i "EBS-KEY.pem" ec2-user@ec2-18-232-77-8.compute-1.amazonaws.com) to connect to the instance and verify the attached EBS volume from within the OS.

Top comments (0)