Linux: my disk is full and the server stopped working
poze 3 months ago581 gadeen
My app crashed with "No space left on device". df -h shows / at 100%. How do I find what's eating the space and fix it quickly?
Dyagnostik IA
Se IA ki fè l. Se pa yon repons — kominote a anba a konfime oswa korije l. Toujou verifye anvan ou fye l.
1 Repons
1. Find the culprit:
sudo du -xh / --max-depth=1 2>/dev/null | sort -h | tail
# then drill down, e.g.
sudo du -xh /var --max-depth=1 | sort -h | tail
Or use ncdu / for an interactive view.
2. The usual suspects: - Logs: /var/log, especially app logs without rotation. Clear systemd logs with sudo journalctl --vacuum-size=200M. - Docker: images, stopped containers, build cache and container logs:
docker system df
docker system prune -a # removes unused images/containers (careful)
docker builder prune
- Old backups or dumps left on the same disk. - Deleted files still held open: sudo lsof +L1. Restart the process holding them to free the space.
3. Prevent it: configure logrotate, Docker's log limits ("log-opts": {"max-size": "10m", "max-file": "3"} in daemon.json), and an alert at 80% disk usage.
Konekte pou di lòt moun si li te mache.
Sign in and verify your email to post an answer.