Back to lessons

Web Server Rescue

Check Filesystem Space with df

You need to see which mounted filesystem is low on space.

Command

df -h

What changed

Nothing changes. The command reports mounted filesystem usage.

Danger

safe

When to use it

Use when writes fail, logs stop, uploads break, or services report no space left on device.

When not to use it

Do not use it to find the specific large directory; use du for that.

Undo or recovery

No undo needed because this command is read-only.

Expected output

A table of filesystems showing size, used space, available space, use percentage, and mount point.

demo script

Disposable terminal steps

  1. df -h
  2. du -xh --max-depth=1 /var 2>/dev/null | sort -h

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        25G   23G  1.1G  96% /
tmpfs           982M   12M  970M   2% /run
::exit-code::0
$ du -xh --max-depth=1 /var 2>/dev/null | sort -h
24M	/var/tmp
180M	/var/cache
1.4G	/var/log
3.8G	/var/lib
::exit-code::0

YouTube Short

Which filesystem is full?

df answers the first disk question: which mounted filesystem is out of room?

LinkedIn hook

A full disk can break logins, uploads, databases, and deploys.

Question: What usually fills first on your VPS: logs, uploads, cache, or database files?

experiments

A/B tests to run

Metric: save_rate

A: Full disk breaks deploys.

B: Which mount is full?