Fix: VPS Running Out of Disk Space

Estimated reading: 2 minutes

If your VPS disk is full or nearly full, services like MySQL, Nginx, and PHP can crash or refuse to start. Here’s how to find what’s eating your disk and free up space fast.

Step 1: Check Current Disk Usage

df -h

Look at the Use% column for your main partition (usually /). If it’s at 90%+ you need to act now.

Step 2: Find the Largest Files and Folders

Find the top disk-consuming directories:

du -h --max-depth=1 / 2>/dev/null | sort -rh | head -20

Then drill into large folders. For example, if /var is large:

du -h --max-depth=1 /var | sort -rh | head -10

Step 3: Clear Old System Logs

Logs are one of the most common causes of disk bloat. Clean old logs safely:

# Remove old compressed logs
sudo find /var/log -name "*.gz" -delete
sudo find /var/log -name "*.1" -delete

# Truncate large active logs (don't delete them, just empty them)
sudo truncate -s 0 /var/log/syslog
sudo truncate -s 0 /var/log/auth.log

Step 4: Clean Unused Packages and Cache

# Remove unused packages and old kernels
sudo apt autoremove -y

# Clear the apt package cache
sudo apt clean

Step 5: Find and Remove Large Files

Find all files larger than 100MB on your server:

find / -type f -size +100M 2>/dev/null | sort -rh

Common culprits: old database dumps (.sql, .sql.gz), large backup files, and Docker images. Delete anything you no longer need.

Step 6: Clean Docker (If Installed)

Docker can accumulate unused images, containers, and volumes that take gigabytes of space:

# Remove all stopped containers, unused images, volumes, and networks
docker system prune -af --volumes

Warning: This removes all stopped containers and unused images. Running containers are not affected.

Step 7: Upgrade Your Plan

If disk usage is consistently high after cleanup, it may be time to upgrade to a larger VPS plan. Contact Veerhost support at veerhost.com/support to discuss options.