Free up disk space on a Linux VPS

Find what is using space, then safely clear package caches, systemd journal logs, old Docker data and large log files without breaking running services.

  • Beginner
  • Linux VPS
  • 3 min read

By RunRacks Team · Published

A full disk causes strange failures: databases stop writing, uploads fail and even SSH logins can break. Find the cause first, then clean up in order of safety.

1. See how full the disk is

Terminal
df -h
df -i

df -h shows space. df -i shows inodes; if IUse% is 100%, you have too many small files (often sessions or cache) even if space is left.

2. Find the largest folders

Terminal
sudo du -xh --max-depth=1 / 2>/dev/null | sort -h | tail -n 15

Repeat on the biggest result, for example /var, to drill down. For an interactive view, install ncdu (sudo apt install ncdu, or from EPEL on AlmaLinux/Rocky) and run sudo ncdu -x /.

To list single large files:

Terminal
sudo find / -xdev -type f -size +500M -exec ls -lh {} \; 2>/dev/null

3. Clean package caches and unused packages

Ubuntu and Debian:

Terminal
sudo apt clean
sudo apt autoremove --purge

AlmaLinux and Rocky Linux:

Terminal
sudo dnf clean all
sudo dnf autoremove

autoremove also removes old kernels that are no longer needed. Read the list before you confirm.

4. Shrink the systemd journal

Terminal
sudo journalctl --disk-usage
sudo journalctl --vacuum-size=200M

To keep it small permanently, set SystemMaxUse=200M in /etc/systemd/journald.conf and run sudo systemctl restart systemd-journald.

5. Handle large log files

Do not rm a log file that a service is still writing; the space is not freed until the service restarts. Empty it instead:

Terminal
sudo truncate -s 0 /var/log/myapp/huge.log

Then make sure logrotate covers that log so it cannot grow forever.

6. Docker data

Terminal
docker system df
docker system prune

prune removes stopped containers, unused networks and dangling images. Also cap container log size as shown in Install Docker and Docker Compose.

7. Deleted files still using space

If df says the disk is full but du cannot find the files, a process is holding deleted files open:

Terminal
sudo lsof +L1

Restart the service named in the output to release the space.

Troubleshooting

  • Space comes back quickly: something is writing fast. Find it with sudo du -xh --max-depth=2 /var | sort -h | tail a few minutes apart.
  • Old backups on the server: move them off the server; see Back up your Linux VPS.
  • Still not enough room: compare plans on the pricing page. Extra NVMe disk may also be available as an add-on when you order.

Next steps

Was this guide helpful?

Still stuck?

Ask RunRacks AI for a quick answer, or open a ticket and our team will take a look at your server.

Troubleshooting

Fix Nginx 413 Request Entity Too Large

Nginx returns 413 Request Entity Too Large when an upload is bigger than client_max_body_size. Raise the limit for one site or the whole server, match PHP's limits, and test.

  • Beginner
  • Linux VPS
  • 5 min read

Troubleshooting

Is your ISP or router blocking port 12230? How to tell

Work out whether your internet provider, home router, parental controls or a proxy is blocking RDP port 12230, and collect the details support needs to help.

  • Intermediate
  • Windows VPS · Admin RDP
  • 5 min read