A full disk is one of the dumbest and most common ways for a Linux server to fail: the database stops writing, scripts break with unclear errors and services stop accepting connections. Two GNU coreutils commands that ship with every distribution are enough to see it coming. df reports how much space is left on each mounted filesystem, and du reports which directories are consuming it.
The key points of df and du for Linux disk space in 20 seconds
df -hshows used and free space on every filesystem.df -ichecks inodes, which can run out too.du -h -d 1 | sort -rhfinds the largest directories.- If df and du disagree, deleted files are often still held open.
Disk space does not vanish overnight. Logs grow, old backups pile up, Docker images sit uncleaned and temporary files swell for months. By the time something breaks, the disk is already at 100%. This guide builds on a July 2026 walkthrough of df by Sabit and fills in the options it leaves out and the cases where the numbers mislead.
df: how much space each filesystem has left
df (disk free) lists every mounted filesystem with its size, used space, available space, use percentage and mount point. By default it reports 1 KiB blocks, which are hard to read, so most people add -h:
$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 795M 1.9M 794M 1% /run
/dev/sda1 98G 24G 69G 26% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/sda2 50G 30G 20G 60% /homeCode language: PHP (php)
With -h, figures use powers of 1,024 (binary K, M and G). For powers of 1,000, the units drive vendors use, the option is -H. And when a script or report needs the exact figure down to the byte, df -B1 sets the block size to one byte.
These are the options that save the most time day to day:
df -h /var/log: shows only the filesystem that path lives on, which tells you which disk a given directory uses.df -hT: adds a column with the filesystem type (ext4, xfs, btrfs, nfs and so on).df -h -x tmpfs -x devtmpfs: hides memory-backed filesystems, which are not disk space and clutter the output.-t ext4does the opposite and shows a single type.df -h --total: adds a grand total line. Note that it sums everything listed, tmpfs included, so for a real total combine it with-x tmpfs -x devtmpfs.df --output=target,pcent,avail: picks which columns to show and in what order, handy for scripts.
Inodes run out too
On filesystems such as ext4, every file and directory uses one inode, and the total is fixed when the filesystem is created. A server that produces millions of small files (caches, sessions, mail queues) can run out of inodes with gigabytes free, and then it behaves exactly like a full disk: no new files can be created and the “No space left on device” errors are confusing.
$ df -ih
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 6.4M 312K 6.1M 5% /
/dev/sda2 3.2M 2.9M 300K 91% /home
Here /home has space but is at 91% of its inodes and will soon refuse new files. To find the culprit, du --inodes -d 1 /home | sort -rn | head counts inodes instead of bytes. XFS and Btrfs allocate inodes dynamically, so the problem is much rarer there.
du: what is actually using the space
df tells you how full a disk is, not what filled it. That is the job of du (disk usage), which measures a directory and everything in it. Without a depth limit the output is endless, so the practical approach is to stay at the first level and sort:
# Total for one directory
du -sh /var
# First-level subdirectories, largest first
du -h -d 1 /var | sort -rh | head -10Code language: PHP (php)
When the full disk is the root filesystem, adding -x keeps du from wandering into other filesystems mounted below it, such as /home, NFS shares or /proc. Running it with sudo measures directories a normal user cannot read and avoids a flood of permission errors, which can also be silenced with 2>/dev/null.
This sequence solves most cases in under a minute:
- Use
df -hto find which mount point is close to 100%. - List its largest directories with
sudo du -xh -d 1 /mount/point | sort -rh | head -10. - Repeat on the largest directory until you reach the actual files.
The usual suspects are /var/log, /var/lib/docker, /var/cache and home directories. Some tools keep their own counters, which are more reliable than walking their folders: journalctl --disk-usage for systemd logs and docker system df for Docker images, containers, volumes and build cache. For something interactive there is ncdu, and our roundup of modern Linux terminal tools covers duf and dust, more visual takes on df and du.
When df and du do not add up
It is common for df to report an almost full disk while du adds up to much less. There are three usual explanations:
- Deleted files that are still open. If a huge log is deleted while a process holds it open, the name disappears but the space is not freed until the process closes it.
sudo lsof +L1lists those files along with the process holding them. Restarting or reloading that service frees the space. To empty an active log without this problem, truncate it (: > file.log) rather than deleting it. - Reserved blocks. ext4 reserves 5% of the space for root by default, which is why use can hit 100% for normal users while the size column suggests room is left.
sudo tune2fs -l /dev/sda1 | grep -i reservedshows the reservation. On large data disks it can be lowered withtune2fs -m 1, but the root filesystem should keep its margin. - Data hidden under a mount point. If something was written to
/mnt/databefore a disk was mounted there, those files use space on the root filesystem but are covered by the mount andducannot see them.
On Btrfs and ZFS, df figures are approximate because of snapshots, compression and shared volumes. Use btrfs filesystem usage or zfs list there instead.
A simple alert before 100%
Disk space fills gradually, then all at once when the last gigabyte goes. Checking df -h once a week is enough to catch problems at 60% instead of 100%. In production it belongs in monitoring (Prometheus with node_exporter, Zabbix, Netdata or whatever you run), but until then a cron script that warns past a threshold does the job:
#!/bin/sh
# Report filesystems above 85% space usage
THRESHOLD=85
df -P -x tmpfs -x devtmpfs | awk -v t="$THRESHOLD" 'NR>1 { p=$5; sub(/%/, "", p); if (p+0 >= t) print $6 " at " $5 }'Code language: PHP (php)
The -P option forces POSIX output with each filesystem on a single line, so long device names do not break the parsing. Scheduled hourly in cron, the script only prints something when there is a problem, and cron mails that output if the server is set up for it. Running the same logic with df -iP covers inodes too.
Frequently asked questions
What is the difference between df and du?
df shows total, used and free space for each mounted filesystem. du measures how much a given directory and its contents use, so it is the tool for finding what filled the disk.
How do I see exact disk space in bytes with df?
Use df -B1, which sets the block size to one byte. For readable output use df -h (powers of 1,024) or df -H (powers of 1,000).
Why is the disk still full after deleting files?
A process may still have them open. sudo lsof +L1 lists them, and restarting the service that holds them frees the space.
What happens when inodes run out?
No new files can be created even if space is left. Check with df -i and find the directory responsible with du --inodes.
Sources:
- GNU Coreutils: df invocation
- GNU Coreutils: du invocation
- tune2fs(8) manual page
- Docker: docker system df
- Sabit, a walkthrough of the df command (16/07/2026)
