Fix "No Space Left on Device" When df and du Disagree
A field guide to reclaiming Linux disk space when df reports full but du can't find where the bytes actually went.
Key takeaways
- When df shows a full disk but du cannot find the files, the space is held by something with no visible directory entry.
- Check lsof +L1 for deleted files still open, df -i for inode exhaustion, and a bind mount of / for data hidden under a mount point.
- Restart or truncate the holder to free the blocks.
On this page
When df says the disk is full but du can't find the files, the space is held by something with no directory entry. Run lsof +L1 for deleted files a process still holds open, df -i for inode exhaustion, then bind-mount / to find data hidden under a mount point. Restarting or truncating the holder frees the blocks.
Verified against
systemd 262 journald.conf, e2fsprogs 1.47.4 tune2fs and Docker's json-file logging driver, against the freedesktop.org and man7.org man pages and docs.docker.com. Checked October 2026.
You SSH into a box, a service is down, and the logs say No space left on device. df shows the filesystem at 100%, and you go hunting. Nine times out of ten it's boring: a runaway log, a forgotten tarball, a cache that ate the world. The other time, df and du flatly contradict each other, and that case eats an hour if you don't know the pattern. The boring case comes first.
The basic case: find the big stuff
Start at the root of the full filesystem and walk down one level at a time. The -x flag keeps du on a single filesystem so it doesn't wander into /proc, /sys, or other mounts and hand you garbage numbers.
# biggest directories directly under /, human-sorted
$ du -xh --max-depth=1 / 2>/dev/null | sort -h
# then drill into whatever's fat
$ du -xh --max-depth=1 /var 2>/dev/null | sort -h
If ncdu is installed (or you can install it), it is faster to browse:
$ ncdu -x /var
Usual suspects live in /var: /var/log, /var/lib/docker, /var/cache, and package manager leftovers. Clear the obvious offender, confirm df drops, move on. If du finds the space, you're done. If it doesn't, keep reading.
When df and du disagree
This is the scenario that sends people in circles. df insists the disk is full:
$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p1 50G 50G 0 100% /
$ du -xsh /
23G /
df says 50G used. du says 23G. Twenty-seven gigabytes are unaccounted for. du walks the directory tree and adds up files it can see; df asks the filesystem how many blocks are actually allocated. When those two numbers diverge, the space is being held by something that has no visible directory entry. There are three common reasons.
Case 1: deleted-but-still-open files
This is the big one. A process opens a file, something deletes it (or log rotation rms it), but the process still holds the file descriptor. The directory entry is gone so du can't see it, but the kernel won't release the blocks until the process closes the handle or dies. The space stays gone until then.
Find them with lsof:
# files marked deleted but still held open (link count below 1)
$ sudo lsof +L1
# or the grep version if +L1 isn't behaving
$ sudo lsof -nP | grep '(deleted)'
You'll get output like this, and the SIZE column tells you who's hoarding:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NLINK NODE NAME
java 2417 app 4w REG 259,1 18253611008 0 1179651 /var/log/app/app.log (deleted)
Eighteen gigabytes, zero links, still open. Two ways to fix it. The clean fix is to restart (or HUP) the process so it releases the descriptor. If you can't restart it right now, truncate the file through its /proc handle without killing anything:
# free the space immediately without restarting the process
$ sudo sh -c ': > /proc/2417/fd/4'
That empties the file the descriptor points at, and the blocks come back instantly. Then go fix the actual cause, which is almost always an app logging to a file that logrotate deletes instead of copytruncate-ing.
Case 2: inode exhaustion
Sometimes there's plenty of space and you still can't write a byte. Every file consumes an inode, and a filesystem has a fixed number of them set at creation time. Fill them up with millions of tiny files and you get No space left on device while df -h shows free gigabytes.
Check the inode table, not the block table:
$ df -i /
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/nvme0n1p1 3276800 3276794 6 100% /
Blocks fine, inodes gone. Now find which directory is spawning files. This counts entries per top-level directory:
# find the directory hoarding inodes
$ for d in /var/*; do printf '%8d %s\n' "$(find "$d" -xdev | wc -l)" "$d"; done | sort -n
Typical culprits: PHP session dirs (/var/lib/php/sessions), mail queues, npm/pip caches, or an app dumping one file per event. The fix is deleting the files, but rm * will choke on the argument list. Use find with -delete:
$ sudo find /var/lib/php/sessions -type f -mtime +2 -delete
Then fix the process so it stops, or add a cron job that reaps them.
Case 3: space hidden under a mount point
If a directory had files in it before something got mounted on top, those files still exist on the underlying filesystem. They're occupying space but they're shadowed by the mount, so you can't see them and du on the mounted tree won't count them.
The trick is to bind-mount the parent somewhere else and look underneath:
$ sudo mkdir /mnt/underlay
$ sudo mount --bind / /mnt/underlay
$ sudo du -xsh /mnt/underlay/var/log # what's hiding under the real mount
$ sudo umount /mnt/underlay
If you find a fat directory there that's empty on the live system, that's your ghost. This bites people when /var or /var/log gets moved to its own volume but the old contents were never cleared off the root partition first.
Two more culprits that look like a full disk
Reserved blocks: the tune2fs man page says the default reservation for privileged processes is normally 5%. On a 50G root that's 2.5G you'll never see as "available" to ordinary users. It exists to limit fragmentation and so system daemons keep working when a runaway process fills the disk. On a big data volume that 5% is pure waste. Check and lower it:
$ sudo tune2fs -m 1 /dev/nvme1n1 # drop a data volume's reserve to 1%
Leave it at 5% on the root filesystem. Only trim it on dedicated data or backup volumes.
journald and Docker logs: both grow without asking. journald's SystemMaxUse defaults to 10% of the filesystem, capped at 4G. Cap it lower in a drop-in such as /etc/systemd/journald.conf.d/size.conf, or vacuum on the spot (our journald log management guide covers the rest):
# /etc/systemd/journald.conf.d/size.conf
[Journal]
SystemMaxUse=500M
$ sudo journalctl --vacuum-size=500M
$ sudo systemctl restart systemd-journald
For Docker, per-container JSON logs live under /var/lib/docker/containers/*/*-json.log. The json-file driver's max-size defaults to -1 (unlimited), so set max-size and max-file in /etc/docker/daemon.json. Docker's docs note existing containers don't pick up the new settings; they apply to containers created after the daemon restart.
Questions people ask
Why does df show a full disk when du shows free space?
du adds up files it can reach through directory entries, while df asks the filesystem how many blocks are allocated. The gap is space with no visible entry: a deleted file a process still holds open, data shadowed under a mount point, or reserved blocks. Run sudo lsof +L1 first, because deleted-but-open log files are the most common cause.
How do I fix "No space left on device" when df -h shows free space?
You have probably run out of inodes, not blocks. Run df -i and look for IUse% at 100%. Every file uses one inode, so millions of tiny files (sessions, caches, mail queues) exhaust them while gigabytes remain free. Find the directory with a per-directory find | wc -l count, then delete with find ... -delete rather than rm *.
How do I free space from a deleted file without restarting the process?
Find the process and descriptor with sudo lsof +L1, which lists open files whose link count is zero. Then truncate through the proc handle, for example sudo sh -c ': > /proc/2417/fd/4'. The blocks return immediately and the process keeps running. Fix logrotate afterwards, using copytruncate or a reload signal so the app reopens its log.
The call we'd make
When df and du agree, it's a cleanup job: find the big directory, delete, done. When they disagree, stop hunting for files and think about what has no directory entry. Our reflex order is lsof +L1 first because deleted-open files are by far the most common surprise, then df -i for inodes, then a bind-mount to check for shadowed data. Fix the space, but always trace it back to the process that caused it, otherwise you're back here next week. And put a monitor on both block and inode usage so the disk tells you before the app does. For the broader playbook on diagnosing a sick box, see our Linux troubleshooting guide.
Sources
Cite this article
Kiril Urbonas (2026). Fix "No Space Left on Device" When df and du Disagree. DevOpsNess. Updated 2026-10-31. https://www.devopsness.com/blog/fix-disk-full-linux
[Fix "No Space Left on Device" When df and du Disagree](https://www.devopsness.com/blog/fix-disk-full-linux) (Kiril Urbonas, DevOpsNess, updated 2026-10-31)
More from Linux
Explore more articles in this category
CVE-2026-98432: The CVSS 9.8 Linux TCP Bug Now Has an Exploit. Patched Node Images
A use-after-free in the IPv4 TCP handshake, present since Linux 4.4, now has a working exploit against MPTCP listeners, and every Go 1.24+ server is one by default. Which kernels are fixed and how to roll them through EKS, GKE and AKS.
CERN Left Red Hat for Debian: The CPU Baseline Lesson
CERN is moving accelerator control computers to Debian because RHEL raised its minimum CPU level. Check your own fleet's x86-64-vN support before the next OS upgrade does it for you.
ext4 vs XFS vs Btrfs: Choosing a Filesystem for a Server
The default filesystem your distro picks is not always the right one for your workload. Here is what actually differs and when each one wins.
You might have missed
Evergreen posts worth revisiting.