When your VPS disk reaches 100%, applications stop writing data, databases can corrupt, and the server may become completely unusable. The immediate fix is to identify what is consuming the space and remove it; the permanent fix is to set up alerts and automated cleanup routines so it never happens again.
This guide walks you through it step by step: quick diagnosis, safe cleanup, and automated prevention.
Step 1 — Confirm the Disk Is Full and Locate the Culprit
Before deleting anything, understand exactly where the space went.
Essential Diagnostic Commands
# View disk usage by partition
df -h
# View how much each top-level directory consumes
du -sh /* 2>/dev/null | sort -rh | head -15
# Find the 20 largest files on the system
find / -xdev -type f -size +100M 2>/dev/null | xargs du -sh | sort -rh | head -20
df -h will instantly tell you if / is at 100%. Then use du to drill down to the offending directory — typically /var/log, /var/www, /home, or /tmp.
Step 2 — The Most Common Causes of a Full VPS Disk
90% of cases fall into one of these categories:
Logs That Are Never Rotated or Cleaned
Apache, Nginx, MySQL, and application logs grow indefinitely without logrotate configured. A single Nginx access log can reach several GB on a moderately trafficked site.
# Check the total size of /var/log
du -sh /var/log/* | sort -rh | head -10
# Verify that logrotate is active
logrotate --debug /etc/logrotate.conf 2>&1 | head -30
Accumulated Local Backups
If your backup scripts store copies on the same VPS without deleting old ones, storage runs out in days. Search for large .tar.gz or .sql.gz files:
find /home /var/backups -name "*.tar.gz" -o -name "*.sql.gz" | xargs du -sh 2>/dev/null | sort -rh
Package Cache and Old Kernels
# Ubuntu/Debian: clear apt cache and orphaned packages
apt clean && apt autoremove -y
# CentOS/RHEL: clear dnf/yum cache
dnf clean all
# List installed kernels (older ones can usually be removed)
rpm -q kernel # CentOS
dpkg -l 'linux-image*' | grep ^ii # Ubuntu
Temp Files and Core Dumps
# Clean /tmp (safe in most cases)
rm -rf /tmp/*
# Find core dumps (process crash files)
find / -xdev -name "core" -o -name "core.*" 2>/dev/null
MySQL/MariaDB Binary Logs
MySQL binary logs can consume tens of GB. If you do not use replication, you can safely purge them:
-- In MySQL/MariaDB:
SHOW BINARY LOGS;
PURGE BINARY LOGS BEFORE DATE_SUB(NOW(), INTERVAL 7 DAY);
Then set in /etc/mysql/mariadb.conf.d/50-server.cnf:
expire_logs_days = 7
Step 3 — Safe Cleanup: What to Delete and What to Leave Alone
| File / Directory | Safe to delete? | Note |
|---|---|---|
/tmp/* |
Yes | Regenerates automatically; safe to empty while the server is running |
Rotated logs in /var/log (*.gz) |
Yes | The .gz files are archived copies |
Active log (nginx/access.log, etc.) |
Truncate, do not delete | Use truncate -s 0 file.log to avoid breaking the open file handle |
| Old local backups | Yes, if already on remote destination | Verify they are on S3/FTP/another server first |
| MySQL binary logs | Yes, via PURGE |
Only if you do not use replication |
/var/www (site files) |
With caution | Only remove what you can positively identify as obsolete |
To safely clear an active log without breaking the writing process:
truncate -s 0 /var/log/nginx/access.log
Find more maintenance tools and guides in our VPS servers section.
Step 4 — Prevention: How to Stop the Disk From Filling Up Again
Configure Logrotate Properly
Make sure logrotate is active with an aggressive policy for high-volume logs. Example for Nginx:
# /etc/logrotate.d/nginx
/var/log/nginx/*.log {
daily
missingok
rotate 7
compress
delaycompress
notifempty
sharedscripts
postrotate
nginx -s reopen
endscript
}
Send Backups Off the VPS
Backups must leave the server. Use an object storage bucket (Backblaze B2, Wasabi, AWS S3) or a second server. Delete local copies after confirming the transfer succeeded.
Disk Alerts: Get Warned Before the Problem Hits
A simple cron script that sends an alert when disk usage exceeds 80%:
#!/bin/bash
USO=$(df / | awk 'NR==2 {print $5}' | tr -d '%')
if [ "$USO" -gt 80 ]; then
echo "ALERT: disk at ${USO}% on $(hostname)" | mail -s "VPS Disk Warning" [email protected]
fi
Add to cron (crontab -e): 0 * * * * /usr/local/bin/check_disk.sh
Expand Your VPS Disk
If storage remains insufficient after cleaning everything up, it is time to scale the volume. Most VPS providers let you increase storage from the control panel without reinstalling. If you need help choosing the right plan for your growth trajectory, the team at elenlace.com can help you size your VPS based on your project's real needs.
Key Takeaways
- Confirm the problem with
df -hand locate the culprit withdu -shbefore deleting anything. - Unrotated logs, accumulated local backups, and MySQL binary logs are the most common causes.
- Truncate active logs with
truncate -s 0; never delete a file if the process writing to it is still running. - Configure logrotate, send backups off the VPS, and set up alerts at 80% disk usage.
- If space is still insufficient after cleanup, expand the volume from your provider's control panel.
Need someone to handle recurring server maintenance for you? Reach out at elenlace.com — we manage your VPS so you can focus on your business.
FAQ
Why does my VPS disk fill up so fast?
The most common reasons are logs growing without rotation policies, backups stored locally without cleanup, and MySQL binary logs accumulating. A VPS with moderate traffic can fill 20 GB in just a few weeks without active rotation and cleanup policies in place.
Is it safe to delete files in /tmp on a production VPS?
Generally yes. /tmp contains temporary files that processes create and clean up on their own. You can empty it while the server is running. The only caution is to avoid deleting active sockets (files starting with a PID number) that some daemons use for inter-process communication.
Can I expand my VPS disk without reinstalling the OS?
Yes, most providers allow live volume scaling from their control panel. After the expansion, you will need to extend the partition with growpart and resize the filesystem with resize2fs (ext4) or xfs_growfs (XFS). Some providers automate this step.
When should I start worrying about disk usage?
Set an alert at 75–80% usage. That gives you time to act calmly. At 90% the risk of write errors is high; at 100% many services stop working immediately.
Further reading
Other providers and guides worth comparing: