VPS Disk Full: How to Find and Clean Up Space
A 100% full disk is worse than it sounds: the database refuses writes, the site throws 500s, and even logs stop recording — leaving you blind. Here is a standard procedure from locating to cleaning.
Step 1: assess globally
Run df -h to see usage per partition and confirm whether the root partition or some mount point is full. If inodes are exhausted (df -i shows 100%) while space remains, you have a tiny-files problem — same approach, but hunt for directories with huge file counts.
Step 2: locate big directories
Drill down from root: du -h --max-depth=1 / 2>/dev/null | sort -rh | head. Enter the largest directory and repeat — two or three rounds pinpoint the culprit.
The five usual suspects
- Logs: rotated logs under /var/log and logs written by your own apps. Shrink the system journal with
journalctl --vacuum-size=200Mand configure logrotate for app logs; - Docker: dangling images and build cache consume huge space — inspect with
docker system df, clean withdocker system prune(confirm nothing in use gets removed); - Old backups: backup scripts that only add and never delete fill a disk within months — add a retention policy;
- Package caches:
apt cleanfrees download caches; - Deleted-but-open files: space is not freed while a process still holds a deleted file's handle — find it with
lsof | grep deletedand restart that process.
Two iron rules when cleaning
First, look before you delete: confirm what a file is for — never rm database directories or actively-written logs. Second, truncate large active files instead of deleting: emptying a live log with truncate -s 0 is safer than removing it. Afterwards, set a disk usage alert (warn above 80%) so the next incident never reaches 100%.
本記事は SharkCloud 編集チームが AI を活用して作成し、人による確認を経て公開しています。