Fix 'No Space Left on Device' (Logs, Docker & Inodes)
How to diagnose disk full errors when df -h looks fine—covering inode exhaustion, deleted-but-open files, journald logs, and Docker bloat.
You'll learn why No space left on device can trigger even when df -h shows free gigabytes, how to find deleted files still held open by a running process, and how to reclaim space safely from journald and Docker.
1. The big idea
Linux filesystems track two separate resources: disk blocks (bytes) and inodes (file metadata slots). Running out of either triggers ENOSPC: No space left on device. Even trickier, deleting a huge log file with rm does not free its disk blocks if a running daemon still holds that file descriptor open.
2. Check blocks, inodes, and hidden open files
Run these three commands first whenever a server reports a full disk:
# 1. Check free bytes per mount
df -h
# 2. Check free inodes per mount (100% IUse = inode exhaustion!)
df -i
# 3. Find large files deleted on disk but still held open by a process
sudo lsof +L1If lsof +L1 shows a deleted 40 GB log file still held by nginx or java, restarting or signaling that service (systemctl reload nginx) releases the file descriptor and frees the 40 GB immediately.
3. Reclaim space from journald and Docker safely
Two of the most common culprits on Linux servers are unrotated systemd journals and dangling Docker build caches:
# Check how much space systemd-journald is using
journalctl --disk-usage
# Cap journald logs to 500 MB without deleting active boot metadata
sudo journalctl --vacuum-size=500M
# Inspect Docker disk usage before cleaning
docker system df
# Remove stopped containers, unused networks, and dangling images/build cache
docker system prune -af --volumes=falseTo keep journald from growing unbounded again, set SystemMaxUse=500M inside /etc/systemd/journald.conf and restart systemd-journald.
Confirm you can distinguish block exhaustion (df -h) from inode exhaustion (df -i), spot unlinked open files with lsof +L1, and cap journald growth with SystemMaxUse.
4. Common pitfalls
| Mistake | Why it fails | Better fix |
|---|---|---|
Only checking df -h | Misses 100% inode exhaustion from millions of tiny files | Always check df -i alongside df -h |
Running rm on an active log | Process keeps file descriptor open; blocks stay allocated | Use truncate -s 0 app.log or configure logrotate |
Running docker system prune --volumes blindly | Deletes unattached persistent volumes (like Postgres data) | Omit --volumes unless you verified backups |
Ignoring /var/log/journal | Default journald cap can consume 10% of the root disk | Set SystemMaxUse=500M in /etc/systemd/journald.conf |
5. What you learned
You now have a fast 3-step diagnostic checklist (df -h, df -i, lsof +L1) and safe cleanup commands for journald and Docker so No space left on device never catches you off guard.