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
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
df -h
df -idf -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
sudo du -xh --max-depth=1 / 2>/dev/null | sort -h | tail -n 15Repeat 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:
sudo find / -xdev -type f -size +500M -exec ls -lh {} \; 2>/dev/null3. Clean package caches and unused packages
Ubuntu and Debian:
sudo apt clean
sudo apt autoremove --purgeAlmaLinux and Rocky Linux:
sudo dnf clean all
sudo dnf autoremoveautoremove also removes old kernels that are no longer needed. Read the list before you confirm.
4. Shrink the systemd journal
sudo journalctl --disk-usage
sudo journalctl --vacuum-size=200MTo 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:
sudo truncate -s 0 /var/log/myapp/huge.logThen make sure logrotate covers that log so it cannot grow forever.
6. Docker data
docker system df
docker system pruneprune 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:
sudo lsof +L1Restart the service named in the output to release the space.
Never delete files inside /var/lib/mysql, /var/lib/postgresql, /var/lib/docker or /boot by hand. Use the database, Docker or package tools instead, or you can lose data or stop the server booting.
Troubleshooting
- Space comes back quickly: something is writing fast. Find it with
sudo du -xh --max-depth=2 /var | sort -h | taila 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.
Related guides
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
Troubleshooting
Fix "Your credentials did not work" in Remote Desktop
Fix rejected RDP logins: username format, the right password, stale saved credentials, account lockout and Remote Desktop permissions.
- Beginner
- Windows VPS · Admin RDP
- 3 min read