When a server’s disk fills up, things break in confusing ways: databases crash or refuse writes, websites return 500 errors, SSH logins hang, package updates fail, and logs stop. The fix is usually quick once you know where to look.

1. Confirm which filesystem is full

df -h
df -i
  • Use% at 100% on / (or another mount) → out of space.
  • IUse% at 100% in df -i → out of inodes, even if bytes are free (jump to step 6).

2. Free a little space immediately

If the disk is completely full, some commands (even tab completion) fail. Quick, safe wins:

sudo apt clean                          # package cache (dnf clean all on RHEL)
sudo journalctl --vacuum-size=200M      # shrink the systemd journal

That usually buys enough room to work comfortably.

3. Find what’s using the space

Biggest directories, staying on the full filesystem:

sudo du -xh -d 1 / 2>/dev/null | sort -h | tail

Keep descending into the largest directory. Or use ncdu -x / interactively. Biggest files:

sudo find / -xdev -type f -size +200M -exec ls -lh {} + 2>/dev/null | sort -k5 -h | tail

More techniques in finding large files.

4. Clean up the usual suspects

Logs

sudo du -sh /var/log/* | sort -h | tail
sudo find /var/log -name "*.gz" -mtime +7 -delete       # old rotated logs
sudo truncate -s 0 /var/log/nginx/huge-error.log        # empty a live log safely

Truncate active logs rather than deleting them (see step 5). A log that grew huge usually points to an error repeating thousands of times — read the last lines and fix the cause.

Docker

docker system df
docker system prune -a          # unused images, stopped containers, build cache (not volumes)

Container logs can also be huge — see Docker logs and docker prune.

Old kernels and packages

sudo apt autoremove --purge

Backups and dumps left in /root, /home or /var/backups — move them off the server.

Database binary logs (MySQL/MariaDB with binlogs enabled):

SHOW BINARY LOGS;
PURGE BINARY LOGS BEFORE NOW() - INTERVAL 3 DAY;

Never delete files inside /var/lib/mysql by hand.

5. Space not freed? Deleted files still open

If you deleted big files but df doesn’t change, a process still has them open:

sudo lsof +L1

Restart the listed service (e.g. sudo systemctl restart nginx) and the space is released. If a restart isn’t possible right now, you can truncate the open file through /proc:

sudo truncate -s 0 /proc/<PID>/fd/<FD>

(PID and FD come from the lsof output.)

6. Out of inodes

Millions of small files — PHP sessions, cache fragments, mail queue entries, tiny log files — can exhaust inodes. Find directories with the most files:

sudo du --inodes -xd 1 / 2>/dev/null | sort -n | tail

Keep descending, then clear the offending directory (for example old PHP sessions):

sudo find /var/lib/php/sessions -type f -mmin +1440 -delete

Details in inode usage full.

7. Restart what broke

Services that failed while the disk was full may not recover by themselves:

systemctl --failed
sudo systemctl restart mysql nginx php8.3-fpm

Check database logs for corruption warnings. MySQL/InnoDB and PostgreSQL usually recover cleanly once space is available.

8. Make sure it doesn’t happen again

  • Log rotation for every app log — see logrotate.
  • Journal limits: SystemMaxUse=500M in /etc/systemd/journald.conf.
  • Docker log limits in /etc/docker/daemon.json (max-size, max-file).
  • Backup retention: delete old local copies automatically; keep long-term copies elsewhere.
  • Monitoring: alert at 80–85% — with Netdata, Uptime Kuma push checks, or a cron script (see df command).
  • Cleanup jobs for app caches, temp files and sessions.

9. Or add space

If the data is legitimate and growing, it’s time for more disk:

  • Upgrade to a larger VPS plan (open a ticket with us), then grow the partition and filesystem if it doesn’t happen automatically.
  • Move bulky data (backups, media, archives) to a separate Storage VPS or object storage.

Quick checklist

  1. df -h / df -i — space or inodes?
  2. apt clean, journalctl --vacuum-size — breathing room.
  3. du -xh -d 1 / → drill down.
  4. Clean logs, Docker, packages, backups, binlogs.
  5. lsof +L1 — release deleted-open files.
  6. Restart failed services.
  7. Add rotation, limits and alerts.
  • Linux
  • Disk Space
  • Troubleshooting