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.
Warning: 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.
- Extra NVMe disk may also be available as an add-on when you order.
