The df and du commands both report disk space usage but gather data differently. When their outputs disagree by gigabytes or more, a specific system condition is usually the cause.
Symptoms
-
dfreports a file system at 90%+ usage, butduon the same mount point shows far less space consumed. -
After deleting large files,
dfstill shows the disk as full. -
du -sh /mountpointreturns a total that does not match the "Used" column indf -h.
How df and du differ
The two commands use different system calls and report different things.
| Aspect | df |
du |
|---|---|---|
| Scope | File system level | Files and directories |
| System call | statfs() (reads superblock) |
stat() (reads each file) |
| Default unit | 1-KB blocks | KB |
| Traversal | None (reads superblock metadata) | Depth-first traversal of directory tree |
| Deleted-but-open files | Counted (space still allocated) | Not counted (file no longer in directory tree) |
| Block size option | -B or --block-size=SIZE |
-B or --block-size=SIZE |
Under normal conditions, both commands return similar totals. A large discrepancy points to one of the issues below.
Quick diagnostic triage
Run these commands to identify the cause:
| Step | Command | If output is non-empty, go to |
|---|---|---|
| 1 | sudo lsof +L1 |
Issue 1: Deleted files still held open |
| 2 | mount | grep <mount_point> (look for nested mounts) |
Issue 2: Nested mount points |