What is EBS?
EBS stands for Elastic Block Store. It's like a virtual hard drive that you can attach to your EC2 instances. Unlike your laptop's hard drive, EBS volumes live on AWS's network and can be attached, detached, and reattached to different instances.
Think of it as a USB drive in the cloud. Plug it into one computer, use it, unplug it, and plug it into another. Your data stays there regardless of which instance it's attached to.
EBS Volume Types
General Purpose SSD (gp3) is the default and most versatile. Good for most workloads — boot volumes, development, testing. It's the Honda Civic of storage: reliable, affordable, and gets the job done.
Provisioned IOPS SSD (io1/io2) is for performance-critical databases that need guaranteed input/output operations per second. Think of it as the sports car — fast, expensive, and built for speed.
Throughput Optimized HDD (st1) is for big data and log processing. Cold HDD (sc1) is for infrequent access. Both are cheaper but slower.
Creating and Attaching Volumes
You can create EBS volumes through the console or CLI, then attach them to an EC2 instance. Once attached, you need to format and mount it before you can use it:
sudo mkfs -t ext4 /dev/xvdf
sudo mkdir /mnt/data
sudo mount /dev/xvdf /mnt/data
This creates a filesystem, creates a mount point, and connects the volume. Now you can read and write data to your EBS volume just like any other disk.
Snapshots: Your Backup Plan
EBS snapshots are point-in-time backups of your volumes stored in S3. They're like taking a photo of your hard drive at a specific moment. You can create snapshots anytime and restore from them when things go wrong.
aws ec2 create-snapshot --volume-id vol-0123456789abcdef0 --description "My backup"
Snapshots are incremental — only the changed data since the last snapshot is stored. This makes them efficient and cost-effective. Always take snapshots before making risky changes to your volumes.
EBS vs S3
EBS is block storage — it works like a traditional hard drive and is attached to a single EC2 instance. S3 is object storage — accessible from anywhere and designed for high durability.
Use EBS when you need a file system for your operating system or databases. Use S3 when you need to store files that multiple services or users need to access. They're complementary, not competing solutions.