df: show free disk space
df shows how much space is used and free on each mounted file system. It is the first thing to run when something complains that the disk is full.
df [options] [file or mount point ...]
Examples
df -h # every file system, human-readable
df -h /var # the file system that holds /var
df -hT # include the file system type (GNU)
df -h -x tmpfs -x devtmpfs -x overlay # hide memory and container file systems (GNU)
df -i # inodes instead of blocks
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p2 233G 187G 34G 85% /
/dev/nvme0n1p1 511M 6.1M 505M 2% /boot/efi
/dev/sdb1 3.6T 2.9T 540G 85% /srv/backup
Size minus Used may be more than Avail: ext4 keeps about 5% reserved for root so the system can still work when users fill the disk.
Out of inodes
A file system can be "full" with gigabytes free if it has run out of inodes, the slots that describe files. This happens with millions of tiny files, such as cache or session files. df -i shows it; find the directory with the most files with:
sudo du --inodes -x -d 2 / | sort -n | tail # GNU du
When a disk is full
- Find the big directories with
du. - Clean safe things first: package caches (
sudo apt clean,sudo dnf clean all), old journal logs (sudo journalctl --rotate --vacuum-size=500M), stopped containers, dangling images and build cache (docker system pruneorpodman system prune; add-ato also remove all unused images). - Compress or remove old logs, and check that log rotation works.
- Check for deleted files held open:
sudo lsof +L1. - If the data is legitimate, grow the file system (LVM, VxVM, ZFS, or a bigger cloud disk) rather than deleting.
Other systems
On AIX, df -g shows sizes in gigabytes; on HP-UX, use bdf; on Solaris and illumos, df -h works and zfs list gives a better picture for ZFS pools. macOS supports df -h.