A disk full Linux VPS fails in messy ways: packages will not install, logs stop rotating, MySQL or PHP start throwing errors, and sometimes SSH still works while the application does not. The first job is to confirm whether you are out of space, out of inodes, or both, then to find what is using the space without deleting files you cannot restore.
This walkthrough stays on the command line and assumes you can still open a shell. If the instance will not boot, use the provider’s rescue or console environment and mount the disk read-write only when you are ready to clean it. Keep a snapshot first if the panel offers one, especially before you remove database files or Docker volumes.
Step 1: measure space and inodes separately
Start with both views of the same filesystems:
df -hT
df -i
sudo du -xh --max-depth=1 / 2>/dev/null | sort -h
df -h shows block space. df -i shows inodes. A volume can be 50 percent full on space and 100 percent full on inodes if it holds millions of tiny files, such as mail queues, sessions, or cache objects. In that case, deleting one large ISO will not help. You have to find the directory with the file count.
Note which mount is full. A full / is a different problem from a full /var or a separate data disk. On some VPS images, /tmp or /var/log is its own filesystem. Cleaning the wrong mount wastes time and can look as if “nothing happened.”
If df shows space free and the application still claims the disk is full, look at the quota, a container’s own filesystem, or a process that is writing to a filesystem that is not the one you are watching. The Linux monitoring guide is useful once the box is stable again; right now, df and du come first.
Step 2: find the large directories, then the large files
Once you know the mount, walk it one level at a time so you do not wait on a full-disk du of every user file at once:
sudo du -xh --max-depth=1 /var 2>/dev/null | sort -h
sudo du -xh --max-depth=1 /var/log 2>/dev/null | sort -h
sudo find /var -xdev -type f -size +100M -printf '%s %p\n' 2>/dev/null | sort -n
Common consumers on a VPS are /var/log, /var/lib/docker, /var/lib/mysql or MariaDB’s data directory, backup tarballs in /root or /home, package caches, and old kernel or snap files. The website hosting guide assumes you have room for the site, the logs and a backup; a disk that is already at 95 percent was never going to absorb a sudden spike.
For inode exhaustion, count files instead of bytes:
sudo find /var -xdev -printf '%h\n' 2>/dev/null | sort | uniq -c | sort -nr | head
That is an expensive command on a huge tree, so start in the directory du already pointed at. Session directories, mail spools and cache folders are frequent inode traps.
Step 3: check deleted files that are still held open
This is the usual “I deleted the log and df did not change” case. A process that still has the file open continues to hold the space until it closes the handle or exits:
sudo lsof +L1
sudo lsof | grep -i deleted
If you see a large deleted log held by nginx, php-fpm, mysqld or journald, restart or reload that service after you have rotated or truncated the live file correctly. Deleting a busy log with rm and leaving the process running is how people get stuck. Prefer:
sudo journalctl --disk-usage
sudo journalctl --vacuum-size=200M
# for a regular log file you have already inspected:
sudo truncate -s 0 /var/log/example.log
Truncate only a file you understand. Truncating a database file or a mailbox is data loss, not maintenance. For systemd journals, vacuuming is safer than hunting individual files under /var/log/journal.
Step 4: clean safe caches and old logs first
Work from the least dangerous space you can recover:
# Debian/Ubuntu package cache
sudo apt-get clean
# RHEL-like
sudo dnf clean all
sudo journalctl --vacuum-time=7d
sudo journalctl --vacuum-size=200M
Then inspect application logs and rotate them with the system’s logrotate, rather than emptying files at random. If Docker is installed, unused images and build cache can be huge:
sudo docker system df
# review first; this will remove unused data
sudo docker system prune
Do not run a prune that deletes volumes until you know those volumes are unused. The command will tell you what it wants to remove. Read it.
Old backups on the VPS itself are another frequent guest. If the only copy of a backup is on the same full disk, copy it off before you delete it. The VPS backup and restore guide is built around off-server copies for exactly this reason. A tarball in /root that was meant to be temporary has a way of becoming the last copy.
Step 5: treat databases and mail with more care
If /var/lib/mysql or the MariaDB data directory is the growth, do not delete ibdata, table files or binlogs by hand to “make space.” Check binary log retention, failed imports, and large tables with the database tools. A runaway binlog can fill a disk and then cause the MySQL connection errors you would rather not stack on top of a full volume.
For mail queues, use the mail server’s documented tools. For web caches and sessions, expire them through the application if you can. The goal is a known, reversible cleanup, not a smaller du at any cost.
After you free some space, run a short health check:
df -hT
df -i
sudo systemctl --failed
sudo journalctl -p err --since "1 hour ago" --no-pager
Then complete any package upgrade that failed mid-way, and confirm the site or service responds. If the disk filled during an upgrade, a failed unit may still need sudo dpkg --configure -a or the equivalent on your distribution, once space exists again.
Step 6: decide whether you need a larger disk
Cleanup is the right first move when the space was wasted on logs, caches or forgotten backups. If the data is real and still growing, resize the volume or move data to another disk. A resize is a provider operation plus a filesystem grow, and it deserves a snapshot. The VPS setup guide is a good place to record the new layout so the next full-disk incident is easier to read.
If the provider already enlarged the volume, the guest filesystem may still be the old size. Check with lsblk and df. On many Ubuntu images a cloud growpart service does this on reboot; if it did not, you may need to grow the partition and then the filesystem, for example with growpart and resize2fs on ext4, or xfs_growfs on XFS. Use the documented steps for your image, and never run resize tools on the wrong device. The disk I/O wait guide is the follow-up if the volume is no longer full but still slow.
Set alerts before the disk hits 100 percent. 80 or 85 percent on a small volume is late enough to act and early enough that apt, logs and databases still have room to work. A disk that sits at 98 percent will fill again the first time logrotate or a backup runs.
Frequently asked questions
Why is df high when du does not add up?
Usually a deleted file is still held open, or you ran du on a different mount than the one df is reporting. Check lsof for deleted files, and use du -x so you do not walk into other filesystems.
Can I delete files in /usr or /lib to free space?
Not as a first move, and usually not at all. Removing system libraries or binaries can make the VPS unbootable. Clean logs, caches and known data files first, or use the package manager to remove packages you installed on purpose.
What if the VPS will not boot because the disk is full?
Use rescue mode or the provider console, mount the root filesystem, and free space there, starting with logs and caches. Take a snapshot first if you can. Do not run unfamiliar wipe commands from a forum post against the block device.
Is filling the disk a security incident?
Sometimes it is just a log or a backup. Sometimes a world-writable directory, a public upload form, or an abused mail relay has been filling the disk. After you recover space, look at what wrote the files and when, especially if the growth is in an unexpected path.
Should I add swap when the disk is full?
No. Swap needs disk space, and a full volume is the wrong moment to grow a swap file. Free space first. Swap also will not help if the problem is a full filesystem rather than memory.