Linux

Linux reports 'No space left on device' while df -h shows plenty of free disk space — what is filling my filesystem?

Environment

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

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

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

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

Diagnostic steps

  1. 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.
  1. 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.
  1. 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.
  1. 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.
  1. 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

Confirmed fixes

No fix has been independently verified for this scenario. Treat the causes below as diagnostic hypotheses.

Question

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?

COMMUNITY RESPONSES

Verified community troubleshooting

1 reply
0
agnesdigital Answer
user
Posted 3w ago • 0 confirmations

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.

Showing 1 of 1 community responses
AI DIAGNOSTICS

Incident analysis

Updated 3w ago• Trouble ID

Most likely causes

hypothesis: large files have been deleted but remain open by a process (deleted+held file descriptors), so space not released until process restart 8%
hypothesis: inode exhaustion on the ext4 filesystem caused by many small files (e.g., thousands of tiny logs, caches, or metadata files) 7%
hypothesis: overlayfs/docker metadata (overlay2) created many inode entries and exhausted per-mount inodes; df -i points to overlay mount rather than underlying block device 6%

Summary

Most likely causes: inode exhaustion on the filesystem, deleted files still held open by processes, or overlayfs/docker layer accounting causing perceived full inodes or overlay metadata growth. Each has different diagnostics and recovery paths; prefer reversible, low-impact steps first and verify by creating test files and checking df and lsof.

Suggested Fixes

Diagnostic step 1
Check inode usage per mount: run 'df -i -T' and note any filesystem with IUse% at or near 100%. Result meaning: 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.
Diagnostic step 2
Find large deleted files held open: run 'lsof +L1' or 'lsof | grep deleted' to list processes holding deleted files. Result meaning: 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.
Diagnostic step 3
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'. Result meaning: 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.

Continue troubleshooting

Matched from the title, description and tags