Knowledge base / Linux & server administration

What's filling up my disk? Finding and freeing space

A full disk can stop databases, mail and logging, and sometimes the whole server. Here's how to find the cause quickly.

Which filesystem is full?

df -h      # space
df -i      # inodes: millions of tiny files can fill a disk too

What is using the space?

du -xh --max-depth=1 / | sort -h
du -xh --max-depth=1 /var | sort -h

ncdu -x / gives an interactive view if it's installed. The usual suspects: /var/log, database binary logs, old backups, Docker images (docker system df), and package caches.

Space used but no file to be found?

A deleted file that a process still has open keeps using space until the process closes it:

lsof +L1 | sort -k7 -n | tail

Restart or reload that process (often a log writer) to release the space.

Free space safely