When the disk on your VPS fills up, things start to break: websites and databases can't save data, updates fail, services crash and won't restart, and you may struggle to log in. This guide shows you how to find what's using the space, clear the usual culprits safely, and decide when it's time for a bigger disk.

It works on every operating system we offer: Ubuntu 22.04, 24.04 and 26.04, Debian 12 and 13, AlmaLinux 8, 9 and 10, and Rocky Linux 9 and 10.

This guide is for Linux VPSs you manage yourself. If you have a cPanel web hosting account, see Disk space full or nearly full: find what's using space and free it up instead. If you have a Managed cPanel VPS, open a support ticket rather than deleting system files or logs yourself.

Before you start

  • SSH access as root or as a user with sudo rights. If you're logged in as root, you can leave sudo off the commands.
  • If you can't log in over SSH because the disk is full, use Open Console on your VPS's management page. See Use the web console to access your VPS.
  • Deleted files can't be brought back unless you have a backup. If you're not sure what something is, leave it alone or copy it somewhere else first.

Step 1: Check how full the disk is

df -h

Look at the Use% column for /. Also check inodes, which are the slots for files:

df -i

If IUse% is at or near 100%, you can't create new files even if there's free space. This is caused by huge numbers of small files, such as session files, cache files or a stuck mail queue.

Step 2: Find what's using the space

List the biggest folders at the top level of the disk:

sudo du -xh --max-depth=1 / 2>/dev/null | sort -h | tail -n 15

Then run it again on the biggest folder to dig deeper, for example change / to /var, then /var/log. To list single files over 500 MB:

sudo find / -xdev -type f -size +500M -exec ls -lh {} + 2>/dev/null

If inodes are the problem, count files instead of size:

sudo du -x --inodes --max-depth=1 / 2>/dev/null | sort -n | tail -n 15

ncdu makes this easier. It shows folders sorted by size, and you can move around with the arrow keys and Enter. Press q to quit. Be careful, as pressing d deletes the selected item.

Ubuntu/Debian

sudo apt install -y ncdu
sudo ncdu -x /

AlmaLinux/Rocky

sudo dnf install -y epel-release
sudo dnf install -y ncdu
sudo ncdu -x /

If the disk is completely full, installing packages may fail. Clear some space with Step 3 first.

Step 3: Clear the common space hogs

The systemd journal. System logs can grow to several gigabytes. Check, then trim them to 200 MB:

journalctl --disk-usage
sudo journalctl --vacuum-size=200M

To set a permanent limit, create /etc/systemd/journald.conf.d/size.conf (run sudo mkdir -p /etc/systemd/journald.conf.d first) containing:

[Journal]
SystemMaxUse=500M

Then run sudo systemctl restart systemd-journald.

Package caches. Downloaded package files can be safely removed:

  • Ubuntu/Debian: sudo apt clean
  • AlmaLinux/Rocky: sudo dnf clean all

Old kernels and unused packages. Check the list before you confirm:

  • Ubuntu/Debian: sudo apt autoremove --purge
  • AlmaLinux/Rocky: sudo dnf remove --oldinstallonly --setopt installonly_limit=2 keeps the two newest kernels and never removes the one you're running. To keep fewer in future, set installonly_limit=2 in /etc/dnf/dnf.conf (the default is 3).

Large log files. See which logs are biggest:

sudo du -ah /var/log 2>/dev/null | sort -h | tail -n 15

Old rotated logs, ending in .gz or .1, can be deleted. To empty a log that's still being written to, truncate it rather than deleting it:

sudo truncate -s 0 /var/log/nginx/error.log

If you delete a log a service still has open, the space isn't freed until that service restarts. A log that grows quickly usually means something is going wrong, so read the latest lines and fix the cause. Most system logs are rotated by logrotate. To rotate your own app's logs, create a file in /etc/logrotate.d/, for example /etc/logrotate.d/myapp:

/var/www/myapp/logs/*.log {
    weekly
    rotate 4
    compress
    missingok
    notifempty
    copytruncate
}

Test it with sudo logrotate -d /etc/logrotate.d/myapp.

Deleted files that are still open. If df says the disk is full but du can't find the space, a program may still be holding deleted files open. List them (install the lsof package if needed):

sudo lsof +L1

The COMMAND column shows which program has them. Restart that service, for example sudo systemctl restart nginx, and the space is freed.

Docker. See how much space Docker is using, then remove stopped containers, unused networks, dangling images and build cache:

docker system df
docker system prune

Take care with the extra options. docker system prune -a also removes every image that isn't used by a container, so they'll need to be downloaded again. --volumes also removes volumes not used by a container, which can hold data you want. Check docker volume ls before using it.

Container logs can also grow without limit. To cap them, add this to /etc/docker/daemon.json (merge it with anything already in that file), then run sudo systemctl restart docker. Restarting Docker stops your running containers, and only those with a restart policy start again by themselves. The limit only applies to containers created after the change.

{
  "log-driver": "json-file",
  "log-opts": { "max-size": "10m", "max-file": "3" }
}

MySQL and MariaDB binary logs. If /var/lib/mysql is large and full of files like binlog.000123 or mysql-bin.000123, these are binary logs. Never delete them with rm. Log in with sudo mysql (or sudo mariadb) and run:

SHOW BINARY LOGS;
PURGE BINARY LOGS BEFORE NOW() - INTERVAL 3 DAY;

If you use replication, make sure your replicas have caught up first. To expire them automatically, add binlog_expire_logs_seconds = 604800 (7 days) under [mysqld] in your database's config file and restart it. This works on MySQL 8 and MariaDB 10.6 or newer. On older MariaDB, use expire_logs_days = 7. Newer MariaDB versions may also need slave_connections_needed_for_purge = 0 if you don't use replication.

Old backups and core dumps. Look for backup files left on the server, such as .tar.gz, .zip and .sql files:

sudo find / -xdev -type f \( -name "*.tar.gz" -o -name "*.zip" -o -name "*.sql" -o -name "*.sql.gz" \) -size +100M -exec ls -lh {} + 2>/dev/null

Copy any you need off the server, then delete them. A backup kept on the same disk won't help if the server is lost, so see Back up your VPS off-server with restic. Crash dumps from programs that have crashed are saved in /var/lib/systemd/coredump, or as files named core or core.12345. Once you've dealt with the crash, these can be deleted.

Snap packages (Ubuntu). If you use snaps, old versions are kept. List them with snap list --all; disabled ones are old versions. Remove one with sudo snap remove NAME --revision=NUMBER, and keep fewer in future with sudo snap set system refresh.retain=2.

What not to delete

  • System folders such as /bin, /boot, /etc, /lib, /usr and /var/lib. Remove software with your package manager instead.
  • Database files in /var/lib/mysql or /var/lib/postgresql, and anything in /var/lib/docker. Use the database and Docker commands above.
  • Whole log folders. Some services won't start if their log folder is missing. Empty or delete individual old log files instead.
  • Your swap file, such as /swapfile or /swap.img.
  • /proc, /sys and /dev. They aren't real files on disk, so ignore odd sizes there.

When to add more space

If your server genuinely needs the space, upgrade to a plan with a bigger disk with Upgrade/Downgrade in the left menu of your VPS's management page (Services → My Services → Manage). Then follow Expand your VPS disk after upgrading your plan so your server can use it. Compare plans on our Cloud VPS page.

Troubleshooting

  • "No space left on device" but df -h shows free space: you've run out of inodes. Check with df -i and find the folder with the most files (Step 2).
  • df shows much more used than du finds: look for deleted files that are still open with sudo lsof +L1, and restart the service holding them.
  • /boot is full and updates fail on Ubuntu or Debian: remove old kernels with sudo apt autoremove --purge.
  • A service won't start after the disk filled up: check its logs with sudo journalctl -u SERVICE_NAME -n 50, for example mariadb or nginx, and restart it once there's free space.

Related guides

Need help?

Our Cloud VPS plans are self-managed, so you're responsible for installing, securing and maintaining the software on your server. If something on our side isn't working, such as the network, or your VPS won't boot, open a support ticket. New to your VPS? Start with our Cloud VPS Getting Started Guide.

Was this answer helpful? 0 Users Found This Useful (0 Votes)