Linux: my disk is full and the server stopped working

poze 3 months ago581 gadeen

5

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.

poze 3 months ago

1 Repons

6
✓
✓ Repons yo aksepte

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.

answered 3 months ago

Sign in and verify your email to post an answer.