Log inSign up

Find out what is eating your disk and free it safely

Run df -h to see how full each file system is, then sudo du -xh --max-depth=1 / | sort -h (or the interactive sudo ncdu -x /) to find the folders responsible. The usual culprits are the systemd journal (sudo journalctl --vacuum-size=200M), package caches, old kernels, Docker images and log files, each of which has a safe cleanup command shown below.

Topic: Server basics · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13, Rocky Linux 9, AlmaLinux 9 · Updated 2026-12-03

How do I see how full the disk is?

Use df with human-readable sizes; the Use% column on the line mounted at / is the number that matters on a VPS:

df -h
df -hT -x tmpfs -x devtmpfs
lsblk

The second form shows file system types and hides memory-backed mounts. Your server has one local SSD or NVMe disk, typically /dev/vda, with the root partition on /dev/vda1 or similar. Above about 90 percent, things start to fail in odd ways: databases refuse writes, package installs stop halfway and services cannot write their PID or socket files. Plan to act at 80 percent.

How do I find which folders are largest?

Measure the top level first, then walk down into the biggest entry. -x keeps du on one file system so it does not wander into /proc or other mounts:

sudo du -xh --max-depth=1 / 2>/dev/null | sort -h | tail -15
sudo du -xh --max-depth=1 /var | sort -h | tail -10
sudo du -sh /home/* /opt/* 2>/dev/null | sort -h

On most servers the answer sits under /var (logs, databases, container data) or /home (uploads, build trees, downloads). To list single large files instead of folders:

sudo find / -xdev -type f -size +200M -printf "%s\t%p\n" 2>/dev/null | sort -n | tail -20 | numfmt --field=1 --to=iec

How do I browse usage interactively with ncdu?

ncdu scans once and lets you move through folders with the arrow keys, sorted by size. It is in the main repositories on Ubuntu and Debian and in EPEL on Rocky and Alma:

# Ubuntu and Debian
sudo apt install ncdu

# Rocky Linux and AlmaLinux
sudo dnf install epel-release
sudo dnf install ncdu

sudo ncdu -x /

Press Enter to open a folder, the left arrow to go back, g to toggle the percentage graph and d to delete the selected item after a confirmation. Use the delete key with care; it is easy to remove a database file while scrolling quickly. Press q to quit.

How do I shrink the systemd journal?

Check its size, vacuum it down, then set a permanent cap so it does not grow back:

journalctl --disk-usage
sudo journalctl --vacuum-size=200M
sudo journalctl --vacuum-time=14d

To make the limit stick, create a drop-in file:

sudo mkdir -p /etc/systemd/journald.conf.d
printf "[Journal]\nSystemMaxUse=300M\n" | sudo tee /etc/systemd/journald.conf.d/size.conf
sudo systemctl restart systemd-journald

Classic text logs in /var/log are handled by logrotate. A single huge file there usually means one noisy application; the logrotate guide shows how to rotate it daily and compress old copies. To empty a live log without breaking the program that writes it, truncate instead of deleting: sudo truncate -s 0 /var/log/app.log.

How do I clear package caches and old kernels?

Package managers keep downloaded files and previous kernels, which can add up to a few gigabytes. Clean them with the built-in commands:

# Ubuntu and Debian
sudo apt clean
sudo apt autoremove --purge

# Rocky Linux and AlmaLinux
sudo dnf clean all
sudo dnf remove --oldinstallonly
grep installonly_limit /etc/dnf/dnf.conf

autoremove keeps the running kernel and the newest one, so it is safe after a reboot into the current kernel. On Rocky and Alma, installonly_limit=3 controls how many kernels stay; lowering it to 2 saves space on small disks. Snap packages on Ubuntu keep old revisions too; snap list --all shows them as disabled.

What about Docker images and volumes?

Docker keeps every image layer, stopped container and build cache until you remove it, and all of it lives under /var/lib/docker. See the breakdown and prune what nothing uses:

docker system df
docker image prune -a
docker builder prune
docker container prune

Leave volumes for last and check them by name with docker volume ls, because a volume can hold the only copy of a database. docker system prune -a --volumes removes everything unused in one step and should only be run when you are sure. Container log files are another hidden source; set "log-opts": {"max-size": "10m", "max-file": "3"} in /etc/docker/daemon.json as described in the Docker Engine tutorial.

Why is the disk full when du finds nothing?

Two cases explain this: inodes ran out, or a deleted file is still held open by a running process. Check inodes with:

df -i
sudo find /var -xdev -type f | cut -d/ -f2-4 | sort | uniq -c | sort -n | tail

When IUse% is at 100 percent, millions of tiny files (session files, mail queue entries, cache fragments) are the cause, even though they take little space. For deleted files that still occupy space, list them and restart the owner:

sudo lsof +L1
sudo systemctl restart nginx

Space returns the moment the last process closes the file. This happens often after someone deletes a large log with rm while the service still writes to it.

What if I simply need more space?

Once caches and logs are under control, the lasting fix for steady growth is a larger plan. Disks are not resized in place on our servers: deploy a bigger plan and move your data across, following move to a larger plan. Before that, it helps to know your growth rate. A tiny cron line records it daily:

0 6 * * * df -h / | tail -1 >> /home/deploy/logs/disk.log

The usage monitoring tutorial covers traffic and resource graphs, and the console Usage graphs tab shows the server from the outside. Compare plan sizes on the price list.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A2-4more disk for logs, images and uploads2 vCPU, 4 GB RAM, 100 GB NVMe$14.40/mo$43.20 for 3 months
S2-4larger SSD for storage heavy work2 vCPU, 4 GB RAM, 80 GB SSD$12.00/mo$72.00 for 6 months

Questions about Check disk space and find what fills it

Is it safe to delete files in /var/log?

Old rotated files ending in .1, .gz or a date are safe to remove. For the current log, truncate it with truncate -s 0 rather than deleting it.

Why do df and du show different numbers?

df reports blocks used on the file system, including deleted files still open and reserved blocks, while du adds up the files it can see. lsof +L1 usually explains the gap.

How much free space should I keep?

Aim for at least 15 to 20 percent free. Databases and package upgrades need temporary room, and a full disk can corrupt data that was being written.

Can I clean /tmp?

Files there older than a few days are usually safe to remove, and systemd cleans /tmp on a schedule set in tmpfiles.d. Do not delete sockets or lock files of running services.

Does swap use disk space?

Yes, a swap file takes exactly its size on the root disk. See add a swap file to resize or remove one.