No space left on device: what fills up your VPS disk and how to free it in 10 minutes

Questions and discussions about VPS plans, Linux setup, WordPress, Nginx, NAT and VPS configuration in Bulgaria.
rychy
Site Admin
Posts: 162
Joined: Tue Oct 20, 2026 10:45 am

No space left on device: what fills up your VPS disk and how to free it in 10 minutes

Post by rychy »

🇧🇬 Прочети на български

Your site suddenly returns error 500, MySQL refuses to start, apt stops halfway, and the logs keep repeating the same line: No space left on device. The VPS disk is full. It sounds scary, but the culprit is almost always one of a few well-known ones, and it takes about 10 minutes to fix.

1. Check how much space is left

Code: Select all

df -h
Look at the line for / (the main disk). If Use% is at or near 100%, you are out of space.

Then check the inodes too. That is the number of files the disk can hold, and sometimes they run out before the space does:

Code: Select all

df -i
If IUse% is 100%, the problem is not big files but millions of small ones: usually the cache, sessions or temporary files of some application.

2. Find what takes the space

This command shows the size of every folder in the root, with the largest at the bottom:

Code: Select all

sudo du -xh --max-depth=1 / 2>/dev/null | sort -h
Go into the largest folder and repeat, for example for /var:

Code: Select all

sudo du -xh --max-depth=1 /var 2>/dev/null | sort -h
ncdu is more convenient: it gives you a menu you move through with the arrow keys:

Code: Select all

sudo apt install ncdu     # Ubuntu / Debian
sudo dnf install ncdu     # Rocky / AlmaLinux
sudo ncdu -x /

3. The five most common culprits

📜 System logs (journald)

See how much space they take:

Code: Select all

journalctl --disk-usage
Keep only the last 200 MB:

Code: Select all

sudo journalctl --vacuum-size=200M

📦 Package cache and old kernels

Code: Select all

sudo apt clean && sudo apt autoremove --purge     # Ubuntu / Debian
sudo dnf clean all                                # Rocky / AlmaLinux

🐳 Docker

Docker quietly piles up old images, stopped containers and build cache. First see how much:

Code: Select all

docker system df
Then clean up what is unused:

Code: Select all

docker system prune
⚠️ Careful: docker system prune -a --volumes also deletes every image without a running container and every volume without a container, and volumes often hold the database. Do not run it unless you are sure what is in them.

Separately, container logs grow without limit. See which ones are large:

Code: Select all

sudo du -sh /var/lib/docker/containers/*/*-json.log | sort -h | tail

🌐 WordPress

The most common places in wp-content:
  • wp-content/cache: the cache of a caching plugin, which you can clear from the plugin itself
  • wp-content/updraft, ai1wm-backups and similar: plugin backups that sit on the same disk and grow every month
  • wp-content/uploads: images, often uploaded at full size

Code: Select all

sudo du -sh /var/www/*/wp-content/* 2>/dev/null | sort -h | tail
A backup on the same disk is not a real backup: if the disk fails, you lose both the site and the backup. Download the old backups to your computer and delete them from the server.

👻 A deleted file that still takes space

You deleted a big log, but df still shows a full disk? Some process still holds the file open, and the space is not freed until the process lets go of it:

Code: Select all

sudo lsof +L1
Restart the service from the COMMAND column (for example sudo systemctl restart nginx) and the space comes back.

Next time, do not delete a big log that is being written; empty it instead:

Code: Select all

sudo truncate -s 0 /path/to/file.log

4. How to keep it from happening again

A limit for journald. In /etc/systemd/journald.conf set:

Code: Select all

SystemMaxUse=200M
and restart: sudo systemctl restart systemd-journald

A limit for Docker logs. In /etc/docker/daemon.json:

Code: Select all

{
  "log-driver": "json-file",
  "log-opts": { "max-size": "10m", "max-file": "3" }
}
and sudo systemctl restart docker. It applies to new containers; existing ones need to be recreated.

An alert before it is too late. If you are a VPSStorages customer, the free Monitoring add-on checks every 5 minutes whether the disk is over 90% and sends you an email. That way you find out in time, not from your clients. More: simple monitoring in 15 minutes.

5. If you simply need more space

Sometimes nothing is unnecessary; the project has simply grown. At VPSStorages you can request a plan change from the portal: Start → Plus → Power, and each next plan has a bigger disk. Your data, IP address and SSH port stay the same, and the main partition grows by itself on the next start.

✅ In short

  1. df -h and df -i: space or inodes?
  2. du or ncdu: which folder?
  3. Logs, package cache, Docker, WordPress backups, deleted but open files
  4. Limits for the logs and an alert at 90%
Have a question, or another culprit that is not on the list? Write here!

Return to “VPS questions and setup”