Linux ENOSPC (errno 28) — No Space Left on Device (Deep Dive)
About Linux ENOSPC (errno 28)
Deep dive into ENOSPC covering inode exhaustion, reserved blocks, journal space, tmpfs/RAM disk full, and Docker overlay filesystem space issues. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.
Here are the key things to understand: ENOSPC can occur even when df shows free space — check inode usage with df -i. ext4 reserves 5% of space for root by default (tune2fs -m to adjust). Inode exhaustion: millions of tiny files can exhaust inodes while disk space remains. Docker: container overlay filesystem shares the host's /var/lib/docker partition. tmpfs (including /tmp, /dev/shm) is backed by RAM and has size limits. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.
The most common reasons this occurs include: Disk genuinely full from logs, downloads, or application data. Inodes exhausted — too many small files on the filesystem. Reserved blocks preventing non-root users from writing (ext4 5% reserve). Docker images and containers filling up /var/lib/docker. tmpfs (RAM disk) at capacity, especially /dev/shm for shared memory. Identifying the root cause is the first step toward finding the right solution.
To resolve this, follow these recommended steps: Check disk space: df -h and inode usage: df -i. Find large directories: du -sh /* | sort -rh | head -20. Clean Docker: docker system prune -a --volumes (removes unused images, containers, volumes). Reduce ext4 reserved blocks: sudo tune2fs -m 1 /dev/sdXY (reduce from 5% to 1%). Find and clean old log files: find /var/log -name '*.gz' -mtime +30 -delete. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.
This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.
Quick Answer
Why does df show free space but I get ENOSPC?
Check inodes: df -i. Millions of tiny files can exhaust inodes while disk space remains. Also check if you are a non-root user hitting the 5% reserved blocks.
Overview
Deep dive into ENOSPC covering inode exhaustion, reserved blocks, journal space, tmpfs/RAM disk full, and Docker overlay filesystem space issues.
Key Details
- ENOSPC can occur even when df shows free space — check inode usage with df -i
- ext4 reserves 5% of space for root by default (tune2fs -m to adjust)
- Inode exhaustion: millions of tiny files can exhaust inodes while disk space remains
- Docker: container overlay filesystem shares the host's /var/lib/docker partition
- tmpfs (including /tmp, /dev/shm) is backed by RAM and has size limits
Common Causes
- Disk genuinely full from logs, downloads, or application data
- Inodes exhausted — too many small files on the filesystem
- Reserved blocks preventing non-root users from writing (ext4 5% reserve)
- Docker images and containers filling up /var/lib/docker
- tmpfs (RAM disk) at capacity, especially /dev/shm for shared memory
Steps
- 1Check disk space: df -h and inode usage: df -i
- 2Find large directories: du -sh /* | sort -rh | head -20
- 3Clean Docker: docker system prune -a --volumes (removes unused images, containers, volumes)
- 4Reduce ext4 reserved blocks: sudo tune2fs -m 1 /dev/sdXY (reduce from 5% to 1%)
- 5Find and clean old log files: find /var/log -name '*.gz' -mtime +30 -delete