No space left on device: finding what fills your VPS disk

The error No space left on device means one of two things: the space has run out, or the inodes have (the number of files the disk will accept). Check both with df -h and df -i; then find the guilty folder with du. On an unmanaged VPS cleaning up is yours, and worth doing quickly: with a full disk services stop writing, databases can corrupt and even SSH can refuse you.

Step by step

1 See the space and the inodes. df -h shows, per disk, the size and the percentage used. df -i shows the inodes. If space is at 100% the problem is space; if inodes are at 100% and space is not, it is millions of small files (sessions, caches, mail files).
2 Hunt the big folder, top down. sudo du -xh --max-depth=1 / | sort -h | tail and then step into the biggest: sudo du -xh --max-depth=1 /var | sort -h | tail. The -x stays on the disk it started on. Repeat until you reach the file.
3 Understand what it is before deleting. A big log, a forgotten copy and a container image are cleared in different ways. Never delete a database’s folder by hand.
4 Free what is safe. See the table below.
5 Confirm. df -h again. If you deleted a file and the space did not come back, see the warning about deleted-but-open files.

The usual suspects

Where What to do
/var/log (logs) See what is big and whether logrotate handles it: where the logs are. To empty a log that is in use, sudo truncate -s 0 /var/log/file.log is safer than deleting it.
The systemd journal journalctl --disk-usage and, if large, sudo journalctl --vacuum-size=200M (example).
Package cache (Debian/Ubuntu) sudo apt clean and sudo apt autoremove (the latter removes packages nobody uses any more; read the list before accepting).
/var/lib/docker Images, volumes and container logs: Docker filling the disk.
Backups on the server itself A copy on the same disk takes space and is lost with it. Move it elsewhere: copying with rsync.
Sessions, caches and applications’ temporary files Usually the ones that use up inodes. Each application has its own folder; check its documentation before clearing.
Databases Binary logs and tables that grew. See the database has grown.
Deleted a huge file and the space did not return? A program probably still has it open, and the system frees the space only when it closes it. sudo lsof +L1 lists those files (install lsof if missing) and shows the program; restart that service and the space comes back.
Do not delete blindly outside what you recognise. /boot, /usr, /lib and /etc belong to the system. An rm -rf with a stray space in the path is the fastest way to a server reinstall (reinstalling the operating system).
If the disk is too small for what you do, the answer is not cleaning every week. Check the plan page and your service in Meu Interweb to see what the plan allows for space, or put the heavy data elsewhere. To watch what grows over time, see seeing what uses CPU, memory and disk.

Cannot get in over SSH because the disk is full? The panel console gets you in without the network; tell us what you see.

Open a support ticket

SEE ALSO

Where the logs are on a Linux VPS

Docker filling the disk

Seeing what uses CPU, memory and disk

Common VPS and Cloud errors

RECOMMENDED PRODUCT

VPS server with root access

Resources of your own, the OS you choose, reinstall whenever you like. from 7.560,00 Kz/mo (3-year plan, with coupon)

See plans
  • 0 Users Found This Useful
Was this answer helpful?