An EC2 instance's root volume is at 99% and you can't take downtime. How do you grow it?

BeginnerTroubleshootingDisk, memory and CPU
Answer

Likely causes → The volume was sized too small for logs, data or packages. EBS volumes can be grown online without a reboot.

Diagnose →

df -hT /
lsblk

Fix →

aws ec2 modify-volume --volume-id vol-0abc --size 100
aws ec2 describe-volumes-modifications --volume-ids vol-0abc   # wait for "optimizing" or "completed"
sudo growpart /dev/nvme0n1 1
sudo resize2fs /dev/nvme0n1p1      # ext4
# or
sudo xfs_growfs -d /               # xfs

If the disk is completely full, growpart may fail to write its temp file; free a little space first (old journal logs: journalctl --vacuum-size=200M).

Prevent → Alert at 80% disk with a growth-rate forecast (predict_linear(node_filesystem_avail_bytes[6h], 24*3600) < 0), and keep data and logs on separate volumes.

All Real-World Interview questions Roadmap: Interview readiness

More on Disk, memory and CPU