← back to latest

Check how much disk space is left on every mounted filesystem

df -h

anatomy

df
Disk free. Reports how much space is used and available on each mounted filesystem. Unlike du, which crawls directories and counts files, df asks the kernel for the filesystem-level totals, so it returns instantly regardless of how many files exist.
-h
Human-readable sizes: K, M, G, T instead of raw 1K blocks. Without it the output is in kilobytes, which nobody can read at a glance.

Sample output

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       234G  187G   35G  85% /
tmpfs           7.8G  1.2M  7.8G   1% /dev/shm
/dev/sdb1       932G  548G  337G  62% /data

The root filesystem is at 85% capacity with 35 G remaining. The /data mount has more room. If the root partition is the one filling up, the next step is du -h -d1 / to find out what is consuming it.

When you would reach for it

A deploy fails because there is no space left to write temporary files. A database stops accepting writes. A monitoring alert fires at 90% and you need to see every mount point at once, not guess which one crossed the threshold. df is the first command in any disk triage because it answers the question in under a second.

Gotchas

  • The “Avail” column is often less than “Size” minus “Used” because ext4 reserves 5% of the filesystem for root by default. The space exists but is not available to regular users. Tune it with tune2fs -m if you need it back.
  • On macOS the output includes inode columns (iused, ifree, %iused) that Linux omits by default. The numbers are the same, the table is wider.
  • Virtual filesystems like tmpfs, devtmpfs, and snap mounts clutter the output. Pipe through grep -v tmpfs or use df -h -x tmpfs -x devtmpfs on Linux to filter them out. The -x flag is GNU-specific and does not exist on macOS.

Variants

$ df -h /var/log

Show usage for one mount point. Pass any path and df reports the filesystem that contains it

$ df -ih

Show inode usage instead of block usage. A filesystem can have plenty of space but run out of inodes if it holds millions of tiny files, and the error message is the same: “No space left on device”

$ df -h | awk 'NR>1 && +$5 > 80'

Find filesystems over 80% full. awk skips the header, coerces the Use% column to a number, and prints only the rows that exceed the threshold

lineage

df appeared in Version 1 Unix in 1971, alongside du, as one of the original tools for understanding storage. The earliest version reported free blocks on a single filesystem, because PDP-11 machines often had only one disk. As Unix grew to support multiple mount points, df adapted to report on all of them. The -h flag for human-readable output arrived much later, added to GNU coreutils in the late 1990s as disk sizes moved from megabytes to gigabytes and raw block counts became unreadable. BSD systems added their own -h independently around the same time. POSIX standardized the core behavior but left -h as an extension, which is why every modern implementation supports it even though the standard does not require it. The complementary pairing with du, one tool for the forest and one for the trees, has been a Unix idiom for over fifty years.