Chapter 13: Amazon EBS (Elastic Block Store)
13.7 Detaching a volume safely
Detaching a mounted volume can corrupt data. Always unmount inside Linux first.
# 1. Stop anything using the disk
sudo lsof +f -- /data # list open files on /data (install lsof if missing)
cd ~ # make sure your shell is not inside /data
# 2. Unmount
sudo umount /data # "target is busy" = something still uses it
# 3. Remove or comment the fstab line so boot does not look for it
sudo sed -i.bak '\#[[:space:]]/data[[:space:]]#s/^/#/' /etc/fstab
cat /etc/fstab
- Console: Volumes → select → Actions → Detach volume → confirm. State becomes Available.
- If you no longer need it: take a snapshot (optional) → Actions → Delete volume (stops billing).
Force detach
Force detach is only for emergencies when a normal detach is stuck; it can cause data loss or filesystem corruption.
More on snapshots and AMIs
Hands-on snapshot restores, cross-region copies, AMIs and Data Lifecycle Manager automation are covered step by step in Chapter 14.