The error: A process fails to write a file with "No space left on device," but df -h clearly shows the filesystem has free space available.
Environment: Any Linux system, most commonly seen on servers handling large numbers of small files (mail queues, session caches, log directories).
Why this happens: Disk space and inodes are two separate, independently exhaustible resources. Every file, no matter how small, consumes one inode — and a filesystem can run out of available inodes while still having plenty of raw byte capacity free, especially on systems that accumulate huge numbers of tiny files.
The fix:
- Check inode usage specifically, not just space:
df -ih. - If inodes are at or near 100%, find what's consuming them:
for i in /*; do echo \$i; find \$i | wc -l; donerun from root to narrow down the directory. - Clean up the actual source — commonly a mail queue, a session store, or a logging directory that was never rotated.
- For a longer-term fix if this recurs structurally, the filesystem's inode count is set at creation time and can't be changed without reformatting — worth knowing before you hit this a second time on the same volume.
One thing worth knowing: this is one of the more satisfying "aha" diagnoses in Linux administration precisely because df -h alone actively misleads you — the fix isn't intuitive until you already know inodes exist as a separate resource.