Amazon EBS (Elastic Block Store)
- Amazon EBS is a block storage service provided by AWS that is used with EC2 instances. It acts like a virtual hard disk attached to a server.
Key Features
- Provides block-level storage
- Can be attached to one EC2 instance at a time
- Offers low latency and high performance
- Supports snapshots (backups)
- Requires manual scaling
How It Works
- Create an EBS volume in AWS
- Attach it to an EC2 instance
- Format and mount it like a disk
- Use it for storing data
Use Cases
- Operating system (boot volumes)
- Databases (MySQL, PostgreSQL, Oracle)
- Transaction-heavy applications
- File systems requiring fast access
Types of EBS Volumes
- gp3 / gp2 → General purpose SSD
- io1 / io2 → Provisioned IOPS (high performance)
- st1 → Throughput optimized HDD
- sc1 → Cold HDD (low cost)
Security
- Encryption at rest using AWS KMS
- IAM-based access control
- Snapshot backups for recovery
EBS Volume Mount Commands
Step 1 — Check Attached Disks
lsblk
Step 2 — Partition the Volume (using parted)
sudo parted /dev/nvme1n1
Inside the parted prompt:
(parted) mklabel gpt
(parted) mkpart primary ext4 0% 100%
(parted) quit
mklabel gpt— creates a GPT partition table (recommended for disks > 2TB and modern systems).
mkpart primary ext4 0% 100%— creates a single partition using the full disk.
quit— exits parted.
Step 3 — Format the Partition
sudo mkfs -t ext4 /dev/nvme1n1p1
Step 4 — Create Mount Point & Mount
sudo mkdir /data
sudo mount /dev/nvme1n1p1 /data
Step 5 — Persist Mount (fstab)
sudo su -
Add the following line to /etc/fstab:
/dev/nvme1n1p1 /data ext4 defaults,nofail 0 2
Then test:
sudo mount -a
Step 6 — Verify
df -h
lsblk
mount
Step 7 — Set Ownership
sudo chown ec2-user:ec2-user /data
