How to fix "No space left on device" errors

"No space left on device" means exactly what it says, but the cause is not always obvious. A disk can be full of data, full of tiny files, or hold space that a program has deleted but not released. Whichever it is, the effects are the same: databases stop, logs cannot be written, updates fail and applications crash. This guide finds what is using the space, safely frees it, and stops it recurring.

Step 1: confirm what is full

df -h

Look at the Use% column for each mount. Note the one at or near 100 percent. It may not be the main disk; a separate /var or /home partition can fill on its own.

Then check inodes, which are the slots for files:

df -i

If IUse% is near 100 while df -h shows free space, you have millions of tiny files, such as session files or mail queues. That needs a different fix, below.

Step 2: find the biggest folders

Work from the top down. Start at the root and move into whichever folder is largest:

sudo du -h --max-depth=1 / 2>/dev/null | sort -h | tail -n 10
sudo du -h --max-depth=1 /var | sort -h | tail -n 10

The tool ncdu makes this interactive:

sudo apt install ncdu
sudo ncdu /

Common big spaces:

LocationWhat is usually in it
/var/logLog files that grew without rotation
/var/lib/dockerImages, containers and volumes
/var/lib/mysql or /var/lib/postgresqlDatabases and binary logs
/homeBackups, uploads, downloaded files
/var/cache/aptDownloaded packages
/tmpTemporary files

Step 3: free space safely

Be careful: delete only what you understand, and never remove database files by hand.

Clean package caches

sudo apt clean
sudo apt autoremove --purge

Trim the system journal

sudo journalctl --disk-usage
sudo journalctl --vacuum-size=200M

Handle big logs

Do not simply delete a log file that a program still has open, because the space is not freed. Empty it instead:

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

Then set up rotation so it does not recur. Ubuntu's logrotate reads files in /etc/logrotate.d/.

Clean Docker

docker system df
docker system prune

prune removes stopped containers, unused networks and dangling images. It does not remove volumes unless you add --volumes, which can delete data, so look at what you are deleting first. See How to install Docker on Ubuntu.

Remove old backups and downloads

Review /home and your backup folders. Keep a copy somewhere else before deleting. A good backup plan prunes old copies automatically, as in How to back up your VPS with rsync.

The deleted-but-still-used trap

If you removed a large file and df still shows the disk as full, a running program probably holds it open. Find it:

sudo lsof +L1

This lists files that have been deleted but are still open. Restart the program holding them, and the space returns. This is the most common reason for "I deleted it, but nothing changed."

When it is inodes

If df -i was the problem, find the folder with the most files:

sudo find / -xdev -type f | cut -d/ -f1-4 | sort | uniq -c | sort -n | tail

Typical sources are PHP session folders, mail queues and caches. Clear them with care, for example old files in a session directory:

sudo find /var/lib/php/sessions -type f -mtime +2 -delete

Game and bot servers

On a hosted game server, the limit is your plan's disk allowance, not the whole machine. The usual culprits are:

  • Backups stored on the same server. Download them and delete old ones. See Creating and restoring backups.
  • Log files in the logs folder.
  • World backups and crash reports. Minecraft keeps crash dumps.
  • Unused mods or old world copies.

Use the file manager to sort by size. Use the file manager shows how. Understanding CPU, RAM and disk usage explains the numbers in your dashboard.

Prevent it happening again

  1. Rotate logs and cap the journal size in /etc/systemd/journald.conf.
  2. Prune old backups automatically.
  3. Monitor disk use and get a warning at 80 percent. See How to monitor your VPS with a few basic command line tools.
  4. Schedule cleanups with cron.
  5. Plan capacity. If data keeps growing legitimately, move to a larger plan.

After you free space

Restart anything that failed when the disk filled. Databases in particular may need a check: look at their logs for errors, and run the relevant integrity checks. For services, systemctl --failed lists those that stopped.


Still stuck? Open a ticket on Discord - run /ticket in any channel, pick a department, and include your Server ID or Invoice ID so we can jump straight in.