Detailed Guide to EC2 Instance Storage for Beginners

Amazon EC2 offers various storage options tailored for different workloads. Let’s explore them in detail with simple explanations and steps to get started.


1. Amazon EBS (Elastic Block Store)

Amazon EBS is a persistent block storage system for EC2 instances. Think of it as a virtual hard drive.

Key Features of EBS:

  • Persistent Data: Retains data even if the instance is stopped (but not terminated unless the volume is deleted).

  • Performance: Ideal for transactional workloads like databases or running apps.

  • Customizable Sizes and Types: You can adjust the volume size and type based on your needs.

How to Attach an EBS Volume to an Instance:

  1. Create a Volume:

    • In the AWS Console, go to EC2 Dashboard > Elastic Block Store > Volumes.

    • Click Create Volume.

    • Specify the size (e.g., 10 GB) and type (e.g., gp3 for general SSD).

  2. Attach to an Instance:

    • Select the volume.

    • Click Actions > Attach Volume.

    • Choose the EC2 instance you want to attach it to.

  3. Mount the Volume (Linux):

    • Log in to the EC2 instance.

    • Use commands like lsblk to find the volume and mount it.


2. EBS Snapshots

Snapshots are backups of EBS volumes. They are stored in Amazon S3 and can be used to restore or duplicate volumes.

Why Snapshots Are Useful:

  • Disaster Recovery: Restore lost data.

  • Volume Replication: Create new volumes in the same or a different region.

Steps to Create an EBS Snapshot:

  1. Go to Elastic Block Store > Volumes in the AWS Console.

  2. Select a volume.

  3. Click Actions > Create Snapshot.

  4. Provide a description (e.g., "Backup for app data").

  5. Click Create Snapshot.


3. Amazon Machine Image (AMI)

An AMI is a pre-configured template containing an operating system and any applications you need to launch EC2 instances.

Why Use AMIs?

  • Launch multiple identical instances.

  • Save your instance's current state for later use.

Steps to Create an AMI:

  1. Go to the EC2 Dashboard.

  2. Select your running instance.

  3. Click Actions > Create Image.

  4. Provide an image name and description.

  5. Click Create Image. It will appear under AMIs.


4. EC2 Instance Store

Instance Store is temporary storage directly attached to an EC2 instance.

Key Points:

  • Fast but Temporary: Data is lost if the instance stops or restarts.

  • Use Case: Temporary files like caches.

No setup is needed; it's automatically included with some instance types.


5. EBS Volume Types

EBS offers different volume types for various workloads:

TypeBest ForExample
General Purpose SSD (gp3)Most workloadsWeb servers, dev environments
Provisioned IOPS SSD (io1)High-performance appsDatabases
Throughput Optimized HDDStreaming large dataBig data, logs
Cold HDDInfrequent accessArchive storage

6. EBS Multi-Attach

This feature allows multiple EC2 instances to access a single EBS volume simultaneously.

Why Use Multi-Attach?

  • Shared storage for clustered apps or distributed systems.

Note: Only available for io1 and io2 volumes.


7. EBS Encryption

EBS encryption ensures data at rest and in transit is secure.

How to Enable Encryption:

  1. Go to Volumes in the EC2 Dashboard.

  2. Select a volume.

  3. Click Actions > Modify Volume.

  4. Enable Encryption and save.


8. Amazon Elastic File System (EFS)

EFS is a shared file storage system accessible by multiple EC2 instances.

Why Use EFS?

  • Automatically scales as data grows.

  • Ideal for applications requiring shared storage.

How to Use EFS:

  1. Go to EFS in the AWS Console.

  2. Create a new file system.

  3. Attach it to your EC2 instances using NFS.


9. EFS vs. EBS

FeatureEFSEBS
TypeFile systemBlock storage
AccessShared by multiple instancesSingle instance (or Multi-Attach)
Use CaseShared storage, web serversDatabases, OS boot volumes
PerformanceScales with usageHigh IOPS for critical apps
CostHigher per GBCheaper per GB

Conclusion

Understanding EC2 storage is key to managing your workloads efficiently. Start with EBS for general needs, explore Snapshots for backups, use AMIs for automation, and try EFS for shared storage. Practice with the steps outlined to get hands-on experience!

0
Subscribe to my newsletter

Read articles from Siddhartha Gaurav directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Siddhartha Gaurav
Siddhartha Gaurav

I'm a passionate DevOps engineer with a knack for streamlining development workflows and ensuring seamless deployment pipelines. With experience in managing cloud infrastructure, implementing DevOps best practices, and leveraging automation tools, I thrive on tackling complex challenges and driving efficiency in software delivery. Let's connect and explore how I can contribute to your projects!