Linux reports 'No space left on device' while df -h shows plenty of free disk space — what is filling my filesystem?
Environment
Ubuntu 22.04 LTS host, ext4 root on /dev/sda2 (60G), overlayfs used by Docker 20.10.12; many containers and logs under /var/lib/docker. df -h and df -i run as root.
Symptoms
Applications (systemd services and containers) fail with 'No space left on device' when writing files. New files cannot be created in /var/log and rotating logs fail. df -h shows 25% used, df -i shows 99% used on some mounts.
Observations
df -h: / 60G 15G used 45G available. df -i: / shows IUse% 100% and IFree 0. lsof | grep deleted shows multiple large deleted files held by running processes (docker-containerd, rsyslogd). du -sh /var/lib/docker/overlay2 reports a large apparent size but overlay accounting differs from df.
Already attempted
Restarted rsyslogd and docker daemon; rotated logs with logrotate (manual rotate still fails); ran docker system prune -a (dry-run) and removed few unused images; reboot deferred due to production traffic.
Diagnostic steps
- Check inode usage per mount: run 'df -i -T' and note any filesystem with IUse% at or near 100%.
- What the result means: If IUse% = 100% on the filesystem where writes fail, inode exhaustion is likely and deleting many small files (e.g., cache, tmp) or recreating FS with more inodes is required. If IUse% is low, proceed to check open deleted files.
- Find large deleted files held open: run 'lsof +L1' or 'lsof | grep deleted' to list processes holding deleted files.
- What the result means: If you see processes with large deleted files, their file descriptors still occupy space; restarting or gracefully rotating the service will free space. If none found, deleted-open files are unlikely.
- Compare apparent sizes: run 'du -shx /var/lib/docker' and compare to 'df -h /var/lib/docker'. Also inspect overlay2 metadata counts: 'find /var/lib/docker/overlay2 -xdev -type f | wc -l'.
- What the result means: If du reports much less than df, filesystem-level metadata or deleted-open files may account for the difference. Large counts of small files under overlay2 suggest inode pressure from Docker layers.
- Verify the actual mount pointed at path where writes fail: run 'findmnt /var/log' and 'stat -f /var/log' to confirm the underlying device.
- What the result means: If /var/log is a separate mount that is full while root is not, you need to target that mount. If it's the same device, inode or deleted-open issues are more likely.
- Test creating files: as root, attempt 'touch /tmp/testfile && echo ok > /tmp/testfile' on the problematic mount and check errno and dmesg for ENOSPC or related kernel messages.
- What the result means: If creation fails immediately with ENOSPC, it confirms filesystem-level resource exhaustion. If it succeeds, the issue might be specific to service user permissions, quota, or namespace differences.
Confirmed fixes
No fix has been independently verified for this scenario. Treat the causes below as diagnostic hypotheses.
Question
How can I identify the exact resource causing ENOSPC (inodes vs deleted-open files vs overlayfs inode exhaustion), safely reclaim space without data loss, and verify resolution before scheduling a reboot?
Verified community troubleshooting
First verify whether you’re out of inodes or holding deleted files. Run 'df -i -T' to see inode usage; if IUse% is 100% on the target mount, locate directories with many small files (e.g., 'for d in /var /var/log /var/lib/docker; do echo $d; find $d -xdev -printf "%h " | sort | uniq -c | sort -nr | head; done') and consider removing or archiving old caches. If 'lsof | grep deleted' lists processes with large deleted files, restart just those services (or send SIGHUP if supported) to release space — this immediately frees blocks without reboot. After every action, verify resolution by creating test files on the mount and re-checking 'df -h' and 'df -i'. If inode exhaustion requires reformatting, schedule maintenance and back up data; avoid blind rm -rf on system dirs and escalate for destructive fixes.
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Cloud Computing47% match
Docker image pulls fail with 'no space left on device' though df shows plenty of disk — overlayfs inode exhaustion on Ubuntu 22.04
Open1 answer - Linux45% match
Docker containers report 'no space left on device' after systemd tmpfiles cleaned /var/lib/docker metadata despite free disk space
Open1 answer - Linux27% match
systemd-journald grows log files until root partition fills after logrotate failed on overlay root filesystem
Open0 answers - Cloud Computing27% match
Kubernetes pods OOMKilled while node shows 80GB free memory on Ubuntu 20.04 (kubelet+Docker cgroup mismatch suspected)
Open0 answers - Cloud Computing25% match
Elasticsearch cluster won't relocate shards: 'disk threshold exceeded' though df -h shows free space (EC2 EBS ext4 reserved blocks suspected)
Open0 answers