Skip to content
statance
MenuClose
← All troubleshooting guides

Linux disk is full

Linux

Run df -h to find the full filesystem, then du -xh --max-depth=1 on it to walk down to the largest directories. The usual culprits are logs in /var/log, the systemd journal, package caches, old kernels, Docker images and forgotten backups. Free space from those first rather than deleting files you do not recognise.

Symptoms

  • “No space left on device” errors
  • Databases stop accepting writes or crash
  • Logins fail or services refuse to start

How to diagnose it

  1. Find the full filesystem

    Look for Use% at or near 100%.

    df -h
  2. Find the largest directories

    -x stays on one filesystem so other mounts are not counted. Repeat on the biggest directory to drill down.

    sudo du -xh --max-depth=1 / 2>/dev/null | sort -rh | head -15
  3. Find large files

    List files over 500 MB on the root filesystem.

    sudo find / -xdev -type f -size +500M -exec ls -lh {} + 2>/dev/null
  4. If df and du disagree

    Space can be held by deleted files that a process still has open, or by inodes rather than bytes.

    df -i sudo lsof +L1

Common causes and fixes

Large log files

Truncate a live log instead of deleting it (deleting keeps the space allocated while the process holds it open). Fix log rotation afterwards.

sudo truncate -s 0 /var/log/app/huge.log

systemd journal

Shrink the journal and cap its size.

sudo journalctl --vacuum-size=500M

Package cache and old kernels

Remove cached packages and kernels no longer needed.

sudo apt clean && sudo apt autoremove --purge # Debian/Ubuntu sudo dnf clean all # RHEL/Fedora

Docker images, containers and build cache

Check usage first, then prune. -a removes all images not used by a container.

docker system df docker system prune

Backups or dumps written to the same disk

Move them to separate storage and keep a retention policy.

Prevent it happening again

  • Alert when DISK_used (the fullest mount) is above 85%.
  • Cap the journal with SystemMaxUse= in /etc/systemd/journald.conf.
  • Configure logrotate for every application that writes its own logs.

Set it up: Linux monitoring · Ubuntu monitoring · Debian monitoring.

FAQ

How do I find what is taking up disk space in Linux?

Run sudo du -xh --max-depth=1 / | sort -rh | head, then repeat on the largest directory. ncdu gives an interactive view.

I deleted files but the disk is still full. Why?

A running process still has the deleted file open. Find it with sudo lsof +L1 and restart that process.

Is it safe to delete files in /var/log?

Rotated logs (.1, .gz) are usually safe to delete. Truncate active logs instead of deleting them.

Related guides

Get alerted before this becomes an outage.

Install the agent in one line. Statance watches CPU, memory, disk and services, and its AI assistant helps find the cause.