Block Storage Volumes
Virtual hard drives for VMs
Block storage (EBS, managed disks, Persistent Disk) is a virtual hard drive attached to a VM over the network. It offers raw devices, snapshots, IOPS tiers and the durability semantics a filesystem expects.
What you will learn
- Explain how a block volume maps to physical storage
- Choose volume types and IOPS for workloads
- Snapshot and resize volumes safely
A block volume is a raw device that mounts like /dev/sda1: the OS formats it with a filesystem. Network-attached, it survives instance termination, snapshots capture point-in-time state, and IOPS/size can grow live.
What is this?
AWS EBS types: gp3 (general), io2 (provisioned IOPS), st1 (throughput), sc1 (cold); snapshots are incremental. Azure managed disks: Standard HDD/SSD, Premium SSD, Ultra Disk (extreme IOPS), snapshots and image capture. GCP Persistent Disk (pd-standard, pd-balanced, pd-ssd) with snapshots and regional PDs. Volumes attach to one VM at a time (multi-attach options limited); detach/attach is instant; size and IOPS expand online (increasingly).
Why do you need it?
- VM-local disks are ephemeral (instance store); volumes persist through stop/start.
- Snapshots give cheap, reliable backups and cloning for fleets.
- Throughput/IOPS tiers let you pay for exactly the performance you need.
- Detach/attach enables failover (recover volumes to a healthy instance).
Mental model
External hard drives with a super-fast network cable
Block storage volumes
Each drive has capacity and speed ratings (IOPS), can be unplugged from one computer and plugged into another, and can be snapshot-photographed to preserve its exact contents for restoration.
How it works
- The provider returns a device (e.g. /dev/sda1) over the hypervisor's storage network.
- You format a filesystem (ext4/xfs) and mount it; the drive appears as a normal disk.
- IOPS scale with volume size and type (gp3 baseline 3000 IOPS) or are provisioned (io2).
- Snapshots capture incremental changes; restore by creating a new volume from the snapshot.
- Resize: extend the volume in the API, then grow the filesystem on the OS.
Volume lifecycle.
Examples
Provision and mount a volume
# AWSaws ec2 create-volume --availability-zone us-east-1a --size 100 \ --volume-type gp3 --iops 9000# show device, then on the VM:sudo mkfs -t xfs /dev/sda1 && sudo mkdir /data && sudo mount /dev/sda1 /data# Azure: managed disk then attachaz disk create -n data-disk -g app-rg --size 128 --sku Premium_LRSaz vm disk attach -g app-rg --vm-name web-01 --disk data-diskCreate the volume in the same zone as the VM, attach a device, then let the OS mount it.
In production
- A database stores data files on a provisioned-IOPS (io2/Ultra) volume sized to its workload.
- ELK cluster nodes use freshly sized pd-ssd per node with snapshots before upgrades.
- A build farm snapshots a clean compile volume to clone quickly onto new spot nodes.
Best practices
- Snapshot before any risky in-place operation (resize, filesystem change).
- Choose IOPS from actual workload metrics, not the top SKU.
- Keep volumes in the same zone as the instance; cross-zone attach fails.
- Enable deletion protection where losing the disk is worse than losing the VM.
Common mistakes
- Using instance-store 'ephemeral' disks for data you can't lose.
- Skipping filesystem grow after API resize → space not actually expanded.
- Over-provisioning IOPS that the application never drives.
- Terminating the VM with DeleteOnTermination=true on a database volume.
Common issues
Size grew in console but df unchangedFilesystem not grown after volume resize
Run resize2fs (ext4) or xfs_growfs to extend the filesystem to the new size.
Volume can't attach to another VMZone mismatch or still attached
Verify the volume is in the same AZ/zone and detached from the prior instance.
Debugging tips
- Volume io slow: check the type's baseline IOPS and burst throttle graph.
- After resize, run 'lsblk' and 'resize2fs/xfs_growfs' to confirm the grow took.
- Snapshot missing/old: verify snapshot completion and lifecycle rules.
- Attach conflicts: a volume can be attached to one instance; Detach before moving.
Interview checkpoint
Hands-on lab
- Provision a volume and attach it to a VM
- Write data, snapshot, and restore it
- Resize the volume and grow the filesystem
Create, Attach, Snapshot and Resize a Block Volume
30 min · intermediate
Quick quiz
A snapshot of a volume is a point-in-time copy you can restore by creating a new volume.