When a site becomes slow or stops responding, the cause is usually one of three things: the CPU is overloaded, memory has run out, or the disk is full. This guide shows the handful of commands that tell you which one, and how to recover when the disk fills up.
Which VPS is this for? These steps are for an Unmanaged VPS, where you log in as root and look after the server yourself. On a Managed VPS we take care of the operating system and server software, and you manage your websites in StackCP instead.
The quick health check
uptime # load average nproc # number of CPU cores free -h # memory and swap df -h # disk space per file system df -i # inodes (number of files) systemctl --failed
CPU: reading the load average
uptime shows three numbers, the average load over 1, 5 and 15 minutes. Compare them to your core count from nproc:
- Load below the number of cores: fine.
- Load around the number of cores: busy but coping.
- Load well above the number of cores for long periods: overloaded, requests queue and the site feels slow.
To see what is using the CPU, run htop (install it with sudo apt install htop, or on AlmaLinux/Rocky sudo dnf install epel-release && sudo dnf install htop). Press F6 to sort by CPU% or MEM%, and q to quit. In top, the wa value shows time waiting for disk, and st (steal) shows time the host gave to other work.
Memory: what free -h means
Linux uses spare RAM as disk cache, so the free column is often small. That's normal. Look at the available column: it is how much memory programs can still get. Trouble signs are low available memory together with growing swap use, or processes killed by the kernel:
sudo journalctl -k | grep -i 'out of memory'
Fixes: reduce PHP-FPM workers (pm.max_children), lower MariaDB's innodb_buffer_pool_size, stop unused services or containers, add swap, or upgrade your plan.
Disk: finding what uses space
df -h sudo du -xh --max-depth=1 / 2>/dev/null | sort -h sudo du -xh --max-depth=1 /var 2>/dev/null | sort -h
Keep drilling into the biggest folder. ncdu makes this interactive: sudo apt install ncdu (EPEL on AlmaLinux/Rocky), then sudo ncdu -x /. To list single large files:
sudo find / -xdev -type f -size +500M -exec ls -lh {} \; 2>/dev/null
Fixing a full disk
Signs of a full disk include No space left on device errors, MariaDB refusing to start, WordPress failing to save, and failed updates. Work through the usual suspects, safest first:
1. System journal
journalctl --disk-usage sudo journalctl --vacuum-size=200M
To keep it limited, set SystemMaxUse=200M in /etc/systemd/journald.conf and run sudo systemctl restart systemd-journald.
2. Package caches and old kernels
# Ubuntu / Debian sudo apt clean sudo apt autoremove --purge # AlmaLinux / Rocky sudo dnf clean all sudo dnf autoremove
3. Old log files
Compressed rotated logs (*.gz, *.1) in /var/log can be removed. For a huge active log, empty it instead of deleting it: sudo truncate -s 0 /var/log/nginx/access.log.
4. Docker
docker system df docker image prune -a docker builder prune
Avoid docker volume prune unless you are sure no volume holds data you need. Limit container log size as described in the Docker guide.
5. Old backups and uploads
Backup archives left in /root, /home or /var/backups are a very common cause. Download what you need, then delete them from the server.
6. MariaDB binary logs
If /var/lib/mysql contains many mysql-bin.* or binlog.* files and you don't use replication, remove old ones from the MariaDB shell with PURGE BINARY LOGS BEFORE NOW() - INTERVAL 3 DAY; and set expire_logs_days or binlog_expire_logs_seconds in the config. Never delete these files by hand.
7. Deleted files still held open
If df still shows the disk full after deleting files, a running program is holding them open. Find it and restart that service:
sudo lsof +L1
8. Inodes
If df -i shows 100% but df -h doesn't, you have millions of tiny files (often PHP session or cache files). Find the folder with sudo du --inodes -x --max-depth=2 / | sort -n | tail and clear the cache.
Keep an eye on it
- Run the quick health check weekly, or install a monitoring tool such as Netdata or an external uptime monitor that alerts you by email.
- If your client area shows usage graphs for the VPS, use them to spot trends.
- Aim to keep the disk below 80% full. If it keeps growing, move backups off the server or upgrade to a plan with more storage.
Need help?
If something about the VPS itself is not working (it won't start, you can't reach it, or you need console access, an upgrade or a reinstall), open a support ticket from your client area or message us on WhatsApp at 01818160926. Include your VPS IP address and what you have already tried so we can help faster.
Categories
Written by
FimuroHost Team
Technical Writer