df said 158M used. du said 98M. Both commands were looking at the same 265-megabyte ext4 filesystem on a test container, one right after the other, and the 60 megabytes between them belonged to a log file that had already been deleted. Disk-full problems on Linux are mostly accounting problems, where two honest tools count different things. The usual tutorial says to run du, sort, and delete the biggest folder. That works until the filesystem says it is full and du can’t find what’s filling it. Everything below was run on an Ubuntu 24.04 test container (kernel 6.18, GNU coreutils 9.4, findutils 4.9.0, ncdu 1.19) against small loop-mounted ext4 filesystems built for the purpose, so nothing real was at risk.
Start with df, then walk down with du
One command for the totals, one for the floor plan
df -h answers which filesystem is full. That matters more than it sounds, because /var, /home and a Docker data directory may be separate filesystems, and cleaning the wrong one frees nothing where it counts. The test filesystem held a fake log directory, two database dumps and a pip cache:
$ df -h /mnt/e42
Filesystem Size Used Avail Use% Mounted on
/dev/loop0 265M 158M 87M 65% /mnt/e42
du then breaks the total down by directory. The du man page describes -x as “skip directories on different file systems,” which keeps a scan of / from wandering into network shares and other mounts, and --max-depth=N limits the report to directories “N or fewer levels below the command line argument.” Sorting with sort -h puts the biggest at the bottom:
$ du -xh --max-depth=1 /mnt/e42 | sort -h
16K /mnt/e42/lost+found
7.9M /mnt/e42/home
61M /mnt/e42/var
91M /mnt/e42/srv
158M /mnt/e42
Here the totals agree with df, and the next step is one level down into srv and var. On a real server the first pass is du -xh --max-depth=1 / | sort -h run with sudo, because du as a normal user skips every directory it can’t read and quietly reports a smaller number.

find for big files, ncdu for browsing
Two ways to get to the same suspects
Sometimes the problem is three huge files scattered across a tree rather than one fat directory. find goes straight to them:
$ find /mnt/e42 -xdev -type f -size +40M -printf '%s\t%p\n' | sort -n
47185920 /mnt/e42/srv/backups/db-2026-10-01.sql
47185920 /mnt/e42/srv/backups/db-2026-10-08.sql
-xdev is find’s version of du’s -x. Running it as root over a whole filesystem takes a while on spinning disks, so it pays to point it at the directory du already flagged.
ncdu is “an interactive curses-based version of the well-known du(1)”: it scans once, then lets the arrow keys move through the tree while the sizes stay on screen. Its -x means “Do not cross filesystem boundaries,” and pressing d deletes the selected item, which is convenient and exactly as permanent as rm -r. A capture of its first screen on the test filesystem, later in the run, with the graph bars stripped out:
ncdu 1.19 ~ Use the arrow keys to navigate, press ? for help
-- /mnt/e42
90.0 MiB /srv
30.0 MiB /data
7.8 MiB /home
16.0 KiB /lost+found
12.0 KiB /var
4.0 KiB /scratch
Total disk usage: 127.9 MiB Apparent size: 2.1 G
The bottom line holds a contradiction, 127.9 MiB used and 2.1 G of “apparent size” on a filesystem that only holds 265 megabytes. One sparse file accounts for it. ncdu also has -o, which the manual says will “Export the directory tree in JSON format to file instead of opening the browser interface,” useful for scanning a server once and browsing the result later.
The deleted file that is still full
rm removes the name, and the space waits for the last reader to hang up
The 60-megabyte gap from the opening came from a common mistake: deleting a log file that a running program still has open. On the test filesystem a Python process opened var/log/app/app.log for appending, then the file was removed:
$ rm /mnt/e42/var/log/app/app.log
$ df -h /mnt/e42
Filesystem Size Used Avail Use% Mounted on
/dev/loop0 265M 158M 87M 65% /mnt/e42
$ du -sh /mnt/e42
98M /mnt/e42
df didn’t move. The unlink(2) man page explains it: if the name was the last link but a process still has the file open, “the file will remain in existence until the last file descriptor referring to it is closed.” du walks names, the name is gone, so du can’t count it. df asks the filesystem how many blocks are allocated, and the blocks are still there.
lsof finds these files. Its manual says “+L1” “will select open files that have been unlinked.” On the test container the output also listed unrelated sandbox entries, so it is trimmed here to the relevant line:
$ lsof -nP +L1 /mnt/e42
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NLINK NODE NAME
python3 11736 root 3w REG 7,0 62914560 0 19 /mnt/e42/var/log/app/app.log (deleted)
NLINK 0, size 62,914,560 bytes, file descriptor 3 opened for writing. Restarting the program closes the descriptor and frees the space. When a restart isn’t possible right now, the file can be emptied through the process’s own handle in /proc:
$ : > /proc/11736/fd/3
$ df -h /mnt/e42
Filesystem Size Used Avail Use% Mounted on
/dev/loop0 265M 98M 147M 41% /mnt/e42
Sixty megabytes came back without killing anything. The process keeps writing to the same descriptor, now from zero, and whatever the file held is gone for good, so this trick is for logs nobody needs rather than data anyone does.

Where people get burned
Four cases where the tools disagree and both are telling the truth
Reserved blocks. ext4 keeps a slice of every filesystem for root. The mke2fs man page says the reservation lets “root-owned daemons, such as syslogd(8), to continue to function correctly” and that “The default percentage is 5%.” On the test filesystem that was 3,840 blocks of 4 KiB, 15 MiB. A normal user filled the disk until dd stopped:
$ dd if=/dev/zero of=/mnt/e42/scratch/fill bs=1M # as user tester
dd: error writing '/mnt/e42/scratch/fill': No space left on device
$ df -h /mnt/e42
Filesystem Size Used Avail Use% Mounted on
/dev/loop0 265M 244M 40K 100% /mnt/e42
Size 265M, used 244M, available 40K, and 100% full. Root then wrote another 5 MiB without complaint. The arithmetic in df looks wrong because Avail excludes the reserve, so an app running as a normal user dies while a root shell still has room to clean up. That is the reserve doing its job, and it is also why “the disk has 20 megabytes free” and “the app can’t write” can both be true.
Running out of inodes instead of space. Every file costs one inode, and ext4 fixes the inode count when the filesystem is made. mke2fs warns that the bytes-per-inode ratio cannot be changed “on a file system after it is created.” A second test filesystem was built with only 256 inodes, then given empty files until it refused:
/bin/bash: line 7: /mnt/i42/sessions/sess_244: No space left on device
$ df -h /mnt/i42
Filesystem Size Used Avail Use% Mounted on
/dev/loop1 60M 28K 56M 1% /mnt/i42
$ df -i /mnt/i42
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/loop1 256 256 0 100% /mnt/i42
One percent used and no space left on device. The 244 empty files were enough because a fresh filesystem already counts 11 inodes as used, before anything is written, and the sessions directory took one more. Any directory that collects huge numbers of tiny files can do this on a real server, and df -h will never show it. Counting files per directory finds the culprit:
$ find /mnt/i42 -xdev -type f | cut -d/ -f1-4 | sort | uniq -c | sort -n | tail -3
244 /mnt/i42/sessions
Sparse files. The 2.1 G in the ncdu screen came from one file made with truncate -s 2G:
$ ls -lh srv/vm-disk.img
2.0G srv/vm-disk.img
$ du -h srv/vm-disk.img
0 srv/vm-disk.img
$ du -h --apparent-size srv/vm-disk.img
2.0G srv/vm-disk.img
A two-gigabyte file on a 265-megabyte filesystem, using zero blocks. The du man page says apparent size “may be larger due to holes in (‘sparse’) files.” Virtual machine disks and some database files grow into their apparent size as they’re written, so a VM image that looks harmless in du can fill a disk later, and a copy with a tool that doesn’t preserve holes can turn 0 bytes into 2 GB on the destination.
Files hidden under a mount point. Something wrote 30 MB into an empty data directory, then a tmpfs was mounted on top of it, the way a forgotten backup job can write into /mnt/backup on a night the USB drive wasn’t attached:
$ df -h /mnt/e42
Filesystem Size Used Avail Use% Mounted on
/dev/loop0 265M 128M 117M 53% /mnt/e42
$ du -xsh /mnt/e42
98M /mnt/e42
$ mount --bind /mnt/e42 /mnt/peek && du -sh /mnt/peek/data
31M /mnt/peek/data
df counted 128M, du saw 98M, and nothing was open or deleted. A bind mount of the parent filesystem shows what sits under the mount, without unmounting anything in use.
The journal, Docker and other usual suspects
Big directories with their own cleanup tools
On systemd machines /var/log/journal is a frequent answer to “what grew.” The journald.conf documentation caps it by default: SystemMaxUse= “defaults to 10%” of the filesystem’s size, with the calculated values “capped to 4G,” and SystemKeepFree= defaults to 15%. With Storage=auto the journal persists to disk only if /var/log/journal exists. The test container has no systemd, so these numbers come from the documentation rather than a run here.
journalctl reports its own usage and trims itself:
journalctl --disk-usage
sudo journalctl --vacuum-size=500M
sudo journalctl --vacuum-time=2weeks
The manual adds a catch: vacuuming “only operates on archived journal files,” while --disk-usage includes active ones, so the reported number can stay higher than the target right after a vacuum. Deleting files from /var/log/journal with rm while journald runs brings back the deleted-but-open problem from the previous section.
Docker keeps images, containers and volumes under its own data directory. docker system df “displays information regarding the amount of disk space used by the Docker daemon,” per the Docker CLI reference, and -v shows detail. Docker cleanup can delete volumes that hold real data, and the Docker Compose self-hosting guide is the place to check which volumes a stack actually depends on before pruning anything.

When cleaning up is the wrong fix
Some disks are full because they are supposed to be
The strongest case against everything above is that deleting files is a temporary repair. A log directory that filled once will fill again. A backup directory with no retention policy keeps growing by design, and the two database dumps on the test filesystem are a small picture of that: someone set up the dumps and nobody set up the deletion. The durable fixes are rotation, retention and alerts before 100%, plus a bigger disk when the data really is that size. A disk at 85% with a cron or timer job that reports it, the kind of scheduling covered in the systemd timers vs cron comparison, is a safer state than a disk at 60% that nobody watches.
ZFS and Btrfs change the accounting again, since snapshots keep deleted data alive on purpose and du can’t see it. The ZFS home NAS guide shows how a snapshot starts at zero bytes and grows as live data changes underneath it, and none of the ext4 tests here say anything about how those filesystems count.
Storage trouble also shows up in places that look unrelated. Writers blocked on a stalled filesystem count toward the numbers in the load average explainer, which is how a test machine with idle CPUs reported a load above 3.4.
A short checklist
In order, with sudo
df -h # which filesystem
df -i # inodes, if df -h looks fine
sudo du -xh --max-depth=1 / | sort -h # which directory
sudo find / -xdev -type f -size +500M # which big files
sudo lsof -nP +L1 # deleted but still open
journalctl --disk-usage # the journal
docker system df # Docker, if installed
If df and du still disagree after all of that, the difference is under a mount point, in a snapshot, or in the reserved blocks. The space is somewhere, and the filesystem knows exactly where; it is only the tools that are looking through different windows. What was the strangest thing you ever found eating a disk?
Sources
- du(1) man page: https://man7.org/linux/man-pages/man1/du.1.html
- ncdu manual: https://dev.yorhel.nl/ncdu/man
- unlink(2) man page: https://man7.org/linux/man-pages/man2/unlink.2.html
- lsof manual page: https://lsof.readthedocs.io/en/latest/manpage/
- mke2fs(8) man page: https://man7.org/linux/man-pages/man8/mke2fs.8.html
- systemd journald.conf(5): https://www.freedesktop.org/software/systemd/man/latest/journald.conf.html
- systemd journalctl(1): https://www.freedesktop.org/software/systemd/man/latest/journalctl.html
- Docker CLI reference, docker system df: https://docs.docker.com/reference/cli/docker/system/df/
