Skip to content
Log In Sign Up info@muvcloud.com

Step 1: Blocks or Inodes?

df -h
df -i

df -h shows space per file system. If one is at 100% in the Use% column, data fills it. If space remains but df -i shows IUse% at 100%, every inode is taken: each file uses one, and millions of small files can use them all before the space runs out. How to read df is in how to check disk space in Linux.

Step 2: Find What Uses the Space

sudo du -xh --max-depth=1 / 2>/dev/null | sort -h

The largest folders come last. Repeat inside the largest one, such as /var, until you reach the cause. -x keeps du on one file system. More ways to search are in how to find large files in Linux.

When inodes are full, count files instead of bytes:

for d in /var/*; do echo "$(sudo find "$d" -xdev | wc -l) $d"; done | sort -n

Typical causes are session files, cache folders, and a mail queue that nobody empties.

Step 3: Deleted Files Still Held Open

If df shows the disk full but du finds much less, a program still holds deleted files open. Their space returns only when the program closes them:

sudo lsof +L1

The output names the process and the deleted file, often a log. Restart that service, for example sudo systemctl restart nginx, instead of deleting more files. More about lsof is in the lsof command.

Reserved Blocks on ext4

ext4 keeps a share of blocks, by default 5%, for root, so the system can still write when users have filled the disk. df counts that share as used. Check it with:

sudo tune2fs -l /dev/vda1 | grep -i 'reserved block count'

On a large data disk you may lower it with sudo tune2fs -m 1 /dev/vdb1. Leave the root file system's reserve as it is.

Where the Space Usually Goes

  • Logs: an application log without rotation, under /var/log or the application's folder.
  • System journal: under /var/log/journal.
  • Package caches: downloaded packages kept after installation.
  • Docker: old images, stopped containers, build cache, and volumes under /var/lib/docker.
  • Backups and dumps: archives left on the same disk they protect.

Safe Clean-Ups

Each of these deletes data. Read what it will remove before you run it.

  • Journal: journalctl --disk-usage shows the size; sudo journalctl --vacuum-time=7d deletes archived journal files older than seven days. See journalctl.
  • Package cache: sudo apt clean on Debian and Ubuntu, sudo dnf clean all on AlmaLinux and Rocky Linux. Packages can be downloaded again.
  • Docker: run docker system df first. docker system prune removes stopped containers, unused networks, dangling images, and build cache. -a also removes every unused image, and --volumes also removes anonymous volumes that no container uses, which can hold data. See how to remove Docker images.
  • Backups: move them to other storage before you delete them from the server.

What Not to Do

  • Do not delete a log file a service has open: the space stays used and the service may lose its log. Fix the rotation with logrotate instead.
  • Do not remove files under /var/lib by hand: databases, package managers, and Docker keep live data there.
  • Do not stop at freeing space: find what filled it, or the error returns.

If the server needs more room for good, upgrade the disk and follow how to grow a partition after a disk upgrade.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations