df (disk free) reports how much space is used and available on each mounted filesystem. It’s the first command to run when something fails with “No space left on device”.

Basic usage

df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           393M  1.1M  392M   1% /run
/dev/vda1        59G   41G   16G  73% /
tmpfs           2.0G     0  2.0G   0% /dev/shm
/dev/vda15      105M  6.1M   99M   6% /boot/efi
/dev/vdb1       492G  210G  257G  45% /srv
  • Filesystem — the device (or virtual filesystem).
  • Size / Used / Avail — capacity, used space, space available to normal users.
  • Use% — used ÷ (used + available).
  • Mounted on — the directory where it’s attached. This is what you care about: / is your root disk.

-h uses powers of 1024 (G = GiB); -H uses powers of 1000, like disk manufacturers.

One filesystem or path

df -h /                 # the root filesystem
df -h /var/lib/mysql    # whichever filesystem holds this path
df -h .                 # the current directory's filesystem

Handy for checking where a directory actually lives — for example whether /srv is on the big data disk or the small root disk.

Hide the noise

On systemd systems, many tmpfs and overlay entries clutter the output:

df -h -x tmpfs -x devtmpfs -x squashfs -x overlay
df -h -t ext4 -t xfs     # only these types

Show filesystem types

df -hT

Adds a Type column (ext4, xfs, btrfs, nfs4…).

Inodes

df -i
df -ih /

Every file and directory consumes an inode. A filesystem can run out of inodes while plenty of bytes remain — typical with millions of tiny cache or session files. If IUse% is 100%, see inode usage full.

Custom output

df -h --output=source,fstype,size,used,avail,pcent,target
df --output=pcent / | tail -1        # just the percentage

Useful for scripts and monitoring.

Why Used + Avail ≠ Size

ext4 reserves 5% of blocks for root by default, so system services can still write when users have filled the disk. On a 500 GB data disk, that’s 25 GB invisible to “Avail”. For data-only filesystems you can reduce it:

sudo tune2fs -m 1 /dev/vdb1      # reserve 1%

Keep the default on the root filesystem.

A simple disk space alert

#!/bin/bash
THRESHOLD=85
df -h --output=pcent,target -x tmpfs -x devtmpfs | tail -n +2 | while read pct mount; do
  usage=${pct%\%}
  if [ "$usage" -ge "$THRESHOLD" ]; then
    echo "WARNING: $mount is ${pct} full on $(hostname)"
  fi
done

Run it from cron and pipe the output to mail or a chat webhook. A monitoring tool like Netdata does this with less effort.

df vs du

  • df — filesystem totals, from the filesystem’s own accounting. Fast.
  • du — adds up file sizes by walking directories. Slower, but shows where space goes — see du command.

If df shows a full disk but du can’t find the files, a process is probably still holding deleted files open (sudo lsof +L1). Details in disk full troubleshooting.

Disk full — now what?

  1. df -h — which filesystem is full?
  2. sudo du -xh -d 1 / | sort -h — which directory is big?
  3. Clean up: old logs, Docker images, package caches, old backups.
  4. Make it permanent: log rotation, Docker log limits, backup retention.

Or grow the disk: on a VPS, moving to a larger plan adds space; afterwards, resize the partition if needed.

Quick reference

Task Command
All filesystems, readable df -h
With types df -hT
One path df -h /path
Inodes df -i
Without tmpfs df -h -x tmpfs
Custom columns df --output=…

Our VPS plans include SSD storage from 30 GB upwards, and the Storage VPS offers 500 GB for data-heavy projects.

  • Linux
  • Disk Space
  • Command Line