Skip to main content

Command Palette

Search for a command to run...

"Mastering AWS EC2 and EBS: Attach, Mount, Snapshot & Access Data Across Availability Zones"

Updated
β€’4 min read
"Mastering AWS EC2 and EBS: Attach, Mount, Snapshot & Access Data Across Availability Zones"
G

Gujjar Apurv is a passionate DevOps Engineer in the making, dedicated to automating infrastructure, streamlining software delivery, and building scalable cloud-native systems. With hands-on experience in tools like AWS, Docker, Kubernetes, Jenkins, Git, and Linux, he thrives at the intersection of development and operations. Driven by curiosity and continuous learning, Apurv shares insights, tutorials, and real-world solutions from his journeyβ€”making complex tech simple and accessible. Whether it's writing YAML, scripting in Python, or deploying on the cloud, he believes in doing it the right way. "Infrastructure is code, but reliability is art."

πŸ”° Introduction

This blog is a practical guide to using Amazon EC2 and EBS together. You'll learn how to attach an extra EBS volume to an EC2 instance, mount and store data, and create a snapshot to access that data from another Availability Zone. It's a complete hands-on tutorial for real-world AWS scenarios like data backup, high availability, and cross-AZ storage access perfect for beginners and DevOps learners.

🧠 What You'll Do

  • Launch an EC2 instance

  • Attach an EBS volume

  • Format and mount it

  • Add sample data

  • Create a snapshot

  • Create a volume in another AZ using that snapshot

  • Attach to a new EC2 instance

  • Access the same data cross-AZ

🟒 Step 1: Launch EC2 Instance

  • Go to AWS Console > EC2 > Launch Instance

  • Set:

    • Name: ebs-task-instance

    • AMI: Amazon Linux 2

    • Instance Type: t2.micro

    • Key Pair: Create or choose existing

    • Subnet: e.g., us-east-1c

    • Auto-assign Public IP: Enabled

    • Security Group: Allow SSH (22), HTTP (80) optional

  • Keep default 8 GiB EBS

  • Click Launch

  • After instance is running, connect via:

ssh -i "aws-key.pem" ec2-user@<public-ip>

🟒 Step 2: Create and Attach EBS Volume

  • Go to EC2 > Volumes > Create Volume

  • Set:

    • Size: 10 GiB

    • Type: gp3

    • AZ: us-east-1c (same as EC2)

  • Create Volume

  • Select volume β†’ Actions > Attach Volume

  • Attach to instance as: /dev/sdf

🟒 Step 3: Format and Mount EBS Volume

Inside EC2:

lsblk                          # Check volume as /dev/xvdf
sudo mkfs -t ext4 /dev/xvdf   # Format volume
sudo mkdir /mnt/myvolume      # Create mount point
sudo mount /dev/xvdf /mnt/myvolume  # Mount volume

  • sudo mkfs -t ext4 /dev/xvdf
    πŸ”Ή Formats the volume /dev/xvdf with the ext4 filesystem.

  • sudo mkdir /mnt/myvolume
    πŸ”Ή Creates a directory to serve as a mount point for the volume.

  • sudo mount /dev/xvdf /mnt/myvolume
    πŸ”Ή Mounts the formatted volume to the mount point directory /mnt/myvolume.

🟒 Step 4: Add Sample Data

echo "Hello from Apurv's AWS Volume!" | sudo tee /mnt/myvolume/data.txt
cat /mnt/myvolume/data.txt     # Verify file

🟒 Step 5: Create Snapshot of Volume

  • Go to EC2 > Volumes

  • Select volume β†’ Actions > Create Snapshot

  • Set:

    • Name: data-snapshot

    • Description: Snapshot for cross-AZ access

  • Click Create Snapshot

🟒 Step 6: Create Volume in Another AZ from Snapshot

  • Go to EC2 > Snapshots

  • Select snapshot β†’ Actions > Create Volume

  • Set:

    • AZ: us-east-1a (different from original)

    • Size: 10 GiB

  • Create volume

🟒 Step 7: Launch Second EC2 in Target AZ

  • Launch another EC2 instance

  • Subnet: us-east-1a

  • Use same settings as Step 1

🟒 Step 8: Attach Snapshot-Based Volume

  • Go to EC2 > Volumes

  • Select new volume β†’ Actions > Attach Volume

  • Attach to second EC2 as: /dev/sdf

🟒 Step 9: Mount and Access Data in 2nd EC2

Inside second EC2:

lsblk
sudo mkdir /mnt/myvolume
sudo mount /dev/xvdf /mnt/myvolume
cat /mnt/myvolume/data.txt    # You'll see the same data!

βœ… Conclusion

In this blog, we covered a complete hands-on process of managing storage in AWS using EC2 and EBS. Starting from launching an EC2 instance, attaching a new EBS volume, formatting and mounting it, to writing custom data each step mirrors real-world AWS workflows.

We then created a snapshot of that volume, and used it to create a new volume in a different Availability Zone, proving that:

You can easily access your data from any Availability Zone in AWS by creating volumes from snapshots and attaching them to instances in the target AZ.

This process is not only useful for cross-AZ data access, but also essential for:

  • Disaster recovery

  • High availability setups

  • Data backups and migration

Whether you're preparing for AWS certification or building scalable cloud systems, mastering these EBS and EC2 operations is a foundational skill every cloud or DevOps engineer should have.

πŸ‘¨β€πŸ’» About the Author

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.


πŸ“¬ Let's Stay Connected


πŸ’‘ 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.

More from this blog

T

The OpsVerse with Apurv

26 posts

Sharing hands-on DevOps, AWS, and Cloud tutorials with real-world projects, tips, and automation guides for students and professionals.