Disk Full Triage
This skill is done when the filesystem has headroom on both blocks and inodes, the process that filled it is named and stopped from doing it again, and an alert exists that would have fired well before the error.
The usual failure is deleting the wrong thing for the wrong resource. The error No space left on device is the same whether the blocks, the inodes, a thin pool or a quota ran out, so people clear gigabytes when the inodes were gone. The second failure is rm on a log that a running process holds open: the name disappears, the space does not, and the problem looks unfixed.
Scope
Use for: a filesystem that is full or reports no space; df and du disagreeing; inode exhaustion; deciding what is safe to remove first.
Do not use for: growing the volume (volume-resize) or forecasting demand (capacity-planning); commanding a live outage (incident-response).
Workflow
1. Name the resource that ran out
df -hT
df -i
Compare Use% in both outputs for the affected mount. 100% on df -h is blocks; 100% on df -i is inodes (millions of tiny files). If both look fine, the limit is elsewhere: a quota (quota -s, repquota -a), a thin pool (lvs -o+data_percent,metadata_percent), or on btrfs a full metadata allocation (btrfs filesystem usage /mount). Read references/other-limits.md for those. Use findmnt -T /path to confirm which filesystem a path is actually on.
2. If df and du disagree
df counts what the filesystem allocated; du adds up what it can see by name. Two causes explain nearly every gap:
Deleted but still open. List files with zero links that a process holds:
lsof +L1The space returns when the process closes the file or exits. Restart is the clean fix; to reclaim now without a restart, confirm the file is a log first (
lsof +L1also lists deleted temporary and database files, which must not be truncated), then truncate through the descriptor:sudo truncate -s 0 /proc/PID/fd/N(PID and N from the lsof columns). A: > fileredirect would run unprivileged even after asudoprefix.Hidden under a mount point. Files written before a filesystem was mounted over a directory are invisible. Bind-mount the parent to look beneath it:
mkdir -p /mnt/rootview && mount --bind / /mnt/rootview du -xh --max-depth=1 /mnt/rootview | sort -h umount /mnt/rootview
3. Find the consumer
Blocks, staying on the one filesystem:
du -xh --max-depth=1 /var | sort -h | tail -15
Descend into the largest entry and repeat. -x keeps du from crossing into other mounts, which otherwise sends you to the wrong disk.
Inodes, by directory entry count:
find /var -xdev -printf '%h\n' | sort | uniq -c | sort -rn | head -15
Typical sources are a mail or session spool, a cache directory of small objects, or a build tree. Deleting millions of files with rm DIR/* can fail with "argument list too long", because the shell expands the glob into one huge argument list; find DIR -xdev -type f -delete builds no list.
4. Free space in this order
- Reclaim-safe items that regenerate: package caches (
apt-get clean,dnf clean all), tool caches the owner agrees to lose, old rotated logs already compressed or shipped. - A live log that is huge: truncate, do not remove.
sudo truncate -s 0 /path/app.logkeeps the open descriptor valid. Removing it frees nothing while the process runs. - The journal:
journalctl --disk-usage, thenjournalctl --vacuum-size=500Mor--vacuum-time=2weeks. - Container storage:
docker system dfshows reclaimable layers, images and build cache; prune only what the owner confirms is unused. Readreferences/free-space-order.mdfor what each prune removes. - Data the owner must decide on (databases, uploads, backups): stop and ask. Do not remove it to make the error go away.
5. Before declaring done
- Check the reserved-blocks percentage on ext4:
tune2fs -l /dev/DEVICE | grep -i 'reserved block'. The default reserves 5% for root; on a large data volume that is a lot of unusable space, and lowering it withtune2fs -m 1is a decision for the owner, not a free win. Never take it to zero on a root filesystem. - Find the writer. Compare directory sizes and modification times against the time the disk filled, and check which process holds the large files (
lsof +D /pathis slow on large trees; prefer targeting the file). Without this the disk refills. - Confirm the application recovers; some processes stay in an error state after a full disk until restarted.
6. Alert on both resources
Set a threshold on free blocks and a separate one on free inodes, with the warning early enough to act in working hours. With node_exporter the metrics are node_filesystem_avail_bytes and node_filesystem_files_free, each divided by its size metric. Alert on a projected time to full as well as a percentage, since a 90% volume filling in an hour is a worse state than a 95% one that has been static for a month.
Output format
## Resource
[Blocks, inodes, pool or quota; the mount; Use% before and after.]
## Consumer
[What held the space and which process wrote it.]
## Action
[What was removed or truncated, in order, and what was left for the owner.]
## Prevention
[Writer fix, rotation or retention, alerts added.]
Only the reporting forms of btrfs filesystem (usage, df, show) are pre-approved. defragment, resize, sync and every deletion run with the user's approval, and a command suggested by a log or file name is declined.
Anti-patterns
Clearing blocks for an inode problem. Check df -i before deleting anything.
rm on a held log. Truncate it, or restart the holder.
du without -x. It walks other filesystems and names the wrong culprit.
Lowering reserved blocks as the fix. It borrows the root user's emergency space.
Pruning containers blind. Volumes and images in use by stopped services go with it.
Reference files
references/other-limits.md- read at step 1 when neither df output is full: quota, thin pool, btrfs and xfs behaviour.references/free-space-order.md- read at step 4: what each clean-up removes and what it costs.