HomeBlog"No Space Left on Device": How to Free Disk Space on a VPS
Performance & Tuning3 November 20267 min read

"No Space Left on Device": How to Free Disk Space on a VPS

When a server's disk fills, databases stop writing and sites break. Here is how to find what is using the space in minutes, what is safe to delete, and how to stop it happening again.

💾

Short answer: run df -h to see which disk is full, then du to find the biggest folders. On web servers the space usually goes to old backups kept on the same disk, log files, the systemd journal, database binary logs, or a debug.log left switched on. Clear those, restart anything holding deleted files open, then set an alert so you hear about it at 80%, not 100%.

Find what is using the space

bash
# which filesystem is full?
df -h

# biggest folders on the root disk (stays on one filesystem)
sudo du -xh --max-depth=1 / 2>/dev/null | sort -h | tail -15

# then drill down, e.g.
sudo du -xh --max-depth=1 /var 2>/dev/null | sort -h | tail -10

The usual culprits, and what is safe to remove

WhereWhat it isSafe action
/var/logRotated and compressed logsDelete old *.gz files; check logrotate is running
systemd journalSystem logs kept by journaldsudo journalctl --vacuum-size=200M
apt cacheDownloaded package filessudo apt clean
Backup foldersOld backups stored on the same diskMove off the server; keep only recent local copies
MySQL binary logsbinlog.000123 files in /var/lib/mysqlPURGE BINARY LOGS BEFORE NOW() - INTERVAL 3 DAY; never delete them by hand
wp-content/debug.logWordPress debug log left onDelete it and turn WP_DEBUG_LOG off
wp-content/cache, uploadsPage cache, image copiesClear the cache from the plugin; review oversized uploads

Two traps

  • Deleted but still open: if df still shows the disk full after deleting a big log, a process is holding it. sudo lsof +L1 lists them; restart that service to release the space.
  • Out of inodes: df -h shows free space but writes still fail. df -i shows inodes at 100%, usually from millions of tiny cache or session files.

Never delete files inside /var/lib/mysql by hand, and never rm -rf a folder you have not looked inside. A full disk is an emergency; a deleted database is a disaster.

Stop it happening again

  • Alert on disk usage before it is full (80–85% is a good trigger).
  • Keep backups off the server, not in a folder next to the site.
  • Cap the journal with SystemMaxUse in /etc/systemd/journald.conf.
  • Set binlog_expire_logs_seconds so MySQL removes old binary logs itself.

On GHP Cloud

Backups are stored away from the server's own disk, and you can set a disk-space-low alert that emails you or posts to Slack before the disk fills. The resource graphs show when usage started climbing, and the web terminal lets you run the commands above without setting up SSH.

Frequently asked questions

Why is my website down when the disk is full?

MySQL cannot write, PHP cannot save sessions or uploads, and logs cannot be written, so pages fail with database or 500 errors.

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

Old rotated logs (*.gz, *.1) are safe. Empty an active log with truncate -s 0 instead of deleting it, or the space stays held until the service restarts.

How much free space should a web server keep?

At least 15–20%, more if backups or database dumps are written locally before being moved off.

G

GHP Team

GHP Cloud

Manage WordPress sites the smart way

GHP Cloud gives you a managed server in India with a firewall, malware scanning and daily backups, billed in INR with a GST invoice — from ₹1,450/month.