The Ultimate AWS EBS Workflow: EC2 Integration

Search for a command to run...

No comments yet. Be the first to comment.
Learn AWS from basics to advanced with daily hands-on tasks and real-world projects. Master core services like EC2, S3, IAM, Lambda, and more all explained in a practical, job-ready DevOps format.
โ๏ธ Step-by-Step EC2 Instance Setup with Root SSH Access โ 1. Launching a New EC2 Instance Go to AWS Management Console > EC2 Dashboard Click on Launch Instance Choose an Amazon Machine Image (AMI) โ e.g., Amazon Linux 2 Select the desired Instanc...
Master GitLab CI/CD Variables, Secrets Management, Artifacts & Best Practices ๐ Introduction In the previous article, we learned how GitLab Runners execute CI/CD pipelines and how to configure Self-H

Learn GitLab Runners, Hosted vs Self-Hosted Runners, Runner Registration, Tags, Pipeline Editor & Parallel Jobs ๐ Introduction In the previous article, we created our first GitLab CI/CD pipeline and

Learn Continuous Integration, Continuous Delivery, Pipelines, Stages, Jobs & .gitlab-ci.yml ๐ Introduction In the previous articles, we explored GitLab fundamentals, repository management, and collab

Learn Docker Scout, Multi-Stage Builds, Docker Hardened Images (DHI), SBOM, Docker Model Runner, Ask Gordon AI, and production-ready container security through practical, real-world examples. Introduc

Import Repositories, Mirroring & Repository Management Best Practices ๐ Introduction In the previous articles, we learned the fundamentals of GitLab, created projects, and configured secure authentic

In this guide, I demonstrate the complete lifecycle of working with AWS EC2 and EBS volumes starting from launching an EC2 instance and attaching a new EBS volume, to preserving data by disabling delete-on-termination.
Youโll also learn how to:
Recover EBS data after EC2 termination
Migrate EBS volumes across Availability Zones using snapshots
Copy snapshots across AWS Regions to restore data remotely
This end-to-end workflow ensures data durability, flexibility, and disaster recovery readiness for modern cloud infrastructure setups.
To begin, launch a new EC2 instance:
Go to the EC2 Dashboard in AWS Management Console.
Click on โLaunch Instanceโ.
Select an appropriate AMI (Amazon Machine Image), such as Ubuntu or Amazon Linux.
Choose an instance type (e.g., t2.micro for testing or t3.medium for production).
In the network section, you can keep the default VPC and Subnet settings โ AWS will automatically manage networking unless you have a custom setup.
Continue with key pair, storage, and security group settings.
Once launched, the EC2 instance will automatically have a root EBS volume attached.
When launching an EC2 instance, AWS automatically attaches a root EBS volume to store the operating system and configuration files. By default, this root volume is deleted when the instance is terminated โ but you can control this behavior.
๐ Preserve critical data: Prevents the root EBS volume from being deleted, even if the EC2 instance is terminated.
๐ Easily recover configuration: Retain OS setup, logs, and installed packages for later use or migration.
๐ผ Safe for production use: Especially helpful in staging or production environments where instance termination is temporary or planned.
โ๏ธ Avoid accidental data loss: Ensures your volume (and its data) remains available in the EBS โ Volumes section after termination.
๐ง Attach to a new EC2: The preserved volume can be re-attached to any EC2 instance in the same Availability Zone for instant recovery.



As shown below, AWS automatically creates and attaches a root EBS volume when you launch an EC2 instance.

After launching your EC2 instance, you may need extra storage. For that, you can create a new EBS volume and attach it.
Go to EC2 โ Elastic Block Store โ Volumes โ Create Volume
Select Volume Type, Size, and most importantly, choose the same Availability Zone as your EC2 instance
๐ EBS volumes can only be attached to EC2 instances in the same Availability Zone
After creation, select the volume โ Click Actions โ Attach Volume
Choose your EC2 instance and confirm the device name (e.g., /dev/xvdf)
Click Attach โ your volume is now connected to the instance
โ Youโll now need to format and mount the volume inside the EC2, which weโll do in the next step.
โ Our new EBS volume has been successfully created and is now ready to be attached to the EC2 instance.

๐ Go to Actions โ Attach Volume, then select your EC2 instance to attach the volume.


Once your EBS volume is attached, you need to connect to your EC2 instance and prepare the volume for use.
SSH into your EC2 instance using terminal or any SSH client
(e.g., using .pem key file)
Run the following to verify attached volumes:
lsblk

sudo mkfs -t ext4 /dev/xvdd
mkfs: Stands for โmake file systemโ โ used to format the disk.
-t ext4: Specifies the ext4 file system type (widely used in Linux).
/dev/xvdd: The name of the newly attached EBS volume.
๐ This command prepares the volume for storing files by formatting it.
sudo mkdir /mydata
mkdir: Command to make a new directory.
/mydata: This directory will act as the mount point for the EBS volume.
๐ This is where your EBS volume will be accessible from.
sudo mount /dev/xvdd /mydata
mount: Command to attach the volume to a directory.
/dev/xvdd: The formatted EBS volume.
/mydata: The directory where the volume will be mounted.
๐ This makes the volume usable like a local disk through
/mydata.
df -h
df: Disk free โ shows storage usage.
-h: Human-readable format (GB/MB).
๐ This helps confirm whether the EBS volume is mounted and shows its usage.
echo "This is task for EBS performed by Apurv Gujjar" | sudo tee /mydata/ebs-test.txt
echo: Prints the given message.
| sudo tee: Pipes the message into a file with root permissions.
/mydata/ebs-test.txt: The file to create inside the mounted volume.
๐ This command creates a test file in the EBS volume to validate it's writable.
ls /mydata
ls: Lists all files and folders in the directory.
/mydata: The mount point where the volume is attached.
cat /mydata/ebs-test.txt
๐ Helps you verify that the file (
ebs-test.txt) exists.
cat: Used to display file content in terminal.
/mydata/ebs-test.txt: The test file we just created.
๐ Confirms the file contains the correct data you wrote earlier.


This project is a deep dive into the AWS ecosystem designed to strengthen my foundation in cloud-native architecture, automation, and service integration using only AWS services.
From launching EC2 instances, managing storage with S3 and EBS, configuring IAM for secure access, setting up VPCs and subnets, to automating infrastructure with CloudFormation each service I used brought real-world relevance and clarity to cloud concepts.
This series isn't just about using AWS; it's about mastering the core services that power modern cloud infrastructure.
๐ง Email: gujjarapurv181@gmail.com
๐ GitHub: github.com/ApurvGujjar07
๐ผ LinkedIn: linkedin.com/in/apurv-gujjar
๐ก If you found this project useful, or have any suggestions or feedback, feel free to reach out or drop a comment Iโd love to connect and improve.
This is just the beginning many more builds, deployments, and learnings ahead.