Your production disk is 95% full and the alert just fired. What do you do?
IntermediateScenarioReal-world scenarios
Answer
In one line: Quickly free space safely to prevent an outage, find what filled the disk, then fix the root cause and add earlier alerts and automation so it doesn't happen again.
Step 1 — Check impact and urgency
- Which server/volume? How fast is it growing? Will it hit 100% in minutes or days?
- At 100%, apps can't write logs or data, databases can crash, and services fail — so act quickly but carefully.
Step 2 — Find what's using the space
df -h # which filesystem is full
sudo du -xh / --max-depth=1 | sort -h # biggest top-level folders
sudo du -sh /var/log/* | sort -h # often the culprit
sudo find / -xdev -type f -size +500M -exec ls -lh {} \;
sudo lsof +L1 # deleted files still held open by processes
Common culprits:
- Huge application or debug logs; logs not being rotated.
- Old Docker images, containers and build cache (
docker system df). - Core dumps, temp files, old backups or release folders.
- Database growth or binary logs (MySQL binlogs).
- A deleted log file still held open by a running process (space isn't freed until the process restarts or the file is truncated).
Step 3 — Free space safely
- Compress or remove old rotated logs:
sudo journalctl --vacuum-size=500M. - Truncate (don't delete) an active huge log:
sudo truncate -s 0 /var/log/app/app.log. docker system prune(careful — understand what it removes).- Don't delete files you don't understand, especially database files.
- If needed, expand the volume (EBS volumes can be resized online, then grow the filesystem with
growpartandresize2fs/xfs_growfs).
Step 4 — Fix the root cause
- Configure logrotate or proper log levels; ship logs to a central system instead of keeping them locally.
- Clean up Docker images automatically; set retention policies for backups and artifacts.
- Fix the bug producing excessive logs.
Step 5 — Prevent
- Alerts at 75–80% (ticket) and 90% (page), plus "disk will be full in X hours" predictive alerts.
- Runbook for this alert; automation for safe cleanup.
Tip for interviews: mention the "deleted but still open" file trick (lsof +L1) — it's a classic real-world gotcha.
More on Real-world scenarios
The website is slow. How do you troubleshoot it?IntermediateA deployment to production just failed halfway. What do you do?IntermediateDevelopers complain that the CI pipeline takes 40 minutes. How would you speed it up?IntermediateSomeone accidentally committed an AWS access key to a public GitHub repository. What do you do?IntermediateHow would you set up CI/CD for a brand-new microservice from scratch?IntermediateYour cloud bill doubled this month. How do you find out why and reduce it?Intermediate