Chapter 9 · 9.4
Disk full, memory full or slow
Disk full
A full disk causes strange errors: services that won't start, databases that stop, updates that fail.
anna@web1:~$ df -h /
anna@web1:~$ sudo du -xh --max-depth=1 / | sort -h | tail
anna@web1:~$ sudo du -xh --max-depth=1 /var | sort -h | tail
The usual space hogs:
| What | Clean up |
|---|---|
| Docker images and build cache | sudo docker system df, then sudo docker image prune -a (see Updating containers, cleaning up and limiting logs) |
| Container logs | Set a limit in daemon.json (see Updating containers, cleaning up and limiting logs) |
| The journal | sudo journalctl --vacuum-size=500M |
| Old packages | sudo apt autoremove and sudo apt clean |
| Dumps and backups on the server itself | Keep only the latest; the rest is in restic |
Still too little space after cleaning up? Choose a larger package (see A larger package and more disk space).
Memory full
anna@web1:~$ free -h
anna@web1:~$ ps aux --sort=-%mem | head
anna@web1:~$ sudo journalctl -k | grep -i "out of memory"
If you see Out of memory in the journal, the kernel has stopped a program to free up space. Find out which program is using too much, or give containers a limit. A small swap file can absorb peaks, but it won't fix a structural shortage.
Slow
- Check the Charts tab of the VPS screen to see whether the processor or memory is maxed out for long periods (see The VPS screen: on and off, charts, system and log).
- On the server:
toporhtopshows which program is using the processor. - Lots of traffic from a single address? Check your web server's log. An unknown program keeping the processor fully busy can also be a sign of a break-in (see Hacked? The first steps).
