“No space left on device” is the Linux error you see when a write fails because the filesystem is full. It can stop a database, break apt halfway through an upgrade, crash a container build, or prevent anyone from logging in. And it does not always mean the disk is full of data: the same error appears when a filesystem runs out of inodes, or when deleted files are still held open by a running process.
This guide shows how to confirm which of those you are dealing with, then gives ten fixes in the order that frees space fastest and most safely. Every command works on Ubuntu, Debian, Fedora, RHEL and Arch, with annotated terminal screenshots of what to look for.

The short version
- Run
df -hto see which filesystem is full, anddf -ito check whether it is out of inodes instead. - Find the largest folders with
sudo du -xh --max-depth=1 / | sort -h | tail -20, or installncdu. - The usual culprits are logs, the systemd journal, package caches, Docker images and old snapshots.
- If
dfsays full butducannot find the files, look for deleted files still held open withsudo lsof +L1. - Truncate a large active log file with
truncate -s 0instead of deleting it. - When there is nothing left to clean, grow the disk or volume and the filesystem.
Why Linux says no space left on device
The message comes from the kernel error ENOSPC, which any program can receive when it tries to write. Several different limits produce it, and knowing which one you hit saves a lot of searching:
| Limit | How to check | Typical cause |
|---|---|---|
| Data blocks | df -h |
large files: logs, databases, images, backups |
| Inodes | df -i |
millions of tiny files: sessions, caches, mail |
| Reserved blocks | tune2fs -l |
normal users hit the limit while root still has 5% left |
| User quotas | quota -s |
one user or group used their allowance |
| tmpfs size | df -h /tmp /dev/shm |
RAM-backed folders filled by temporary files |
| Container overlay | docker system df |
image layers and writable container layers |
The reserved-blocks case explains a common puzzle: a normal user sees “no space left on device” while df still shows a few gigabytes available, because those last blocks are reserved for root. Quotas behave the same way for a single user, and a shared hosting account that hits its quota sees the identical error on a disk that is mostly empty.
RAM-backed filesystems deserve a mention too. On many distributions /tmp and /dev/shm live in memory with a size cap, often half of RAM. A large upload, a database import or a build that writes temporary files there can fill them in seconds, and the error names a file in /tmp even though the main disk is fine.
Step 1: find out which filesystem is full
The error message names a file, not a disk. Start by seeing which filesystem is in trouble:
df -h

Look for a Use% of 100% or an Avail of 0. The most common full filesystems are:
| Mount point | Usually filled by |
|---|---|
/ |
logs, packages, Docker, everything else |
/var (if separate) |
logs, databases, container storage |
/boot |
old kernels that were never removed |
/home |
user downloads, caches, virtual machines |
/tmp (often in RAM) |
large temporary files from builds or uploads |
To check the filesystem holding a particular path, add it to the command: df -h /var/lib/mysql. The path in the original error message is the best one to use, because it tells you exactly which filesystem refused the write.
When df shows free space but you still get the error
Run the inode check:
df -i
Every file uses one inode, and a filesystem has a fixed number of them. If IUse% is 100%, you can have gigabytes free and still get “no space left on device”, because there are no inodes left for new files. Fix 5 covers this case. If both space and inodes look fine, see Fix 4 on deleted files.
10 fixes for no space left on device
Work through these in order. The first three find and remove the usual offenders behind no space left on device; the rest handle the stranger cases.

Fix 1: find what is using the space
du measures directory sizes. This command lists the 20 largest folders directly under /, staying on one filesystem with -x:
sudo du -xh --max-depth=1 / 2>/dev/null | sort -h | tail -20

Then repeat it one level deeper on the biggest result, for example /var, then /var/lib, until you find the folder that grew. For an interactive view, install ncdu (sudo apt install ncdu or sudo dnf install ncdu) and run sudo ncdu -x /. It lets you browse folders by size with the arrow keys and delete with d.

To find individual large files rather than folders:
sudo find / -xdev -type f -size +500M -exec ls -lh {} \; 2>/dev/null
Fix 2: shrink the systemd journal
On systemd distributions, the journal can grow to several gigabytes. Check it and trim it, as described in the journald.conf documentation:
journalctl --disk-usage
sudo journalctl --vacuum-size=500M
To keep it from growing back, set a limit in /etc/systemd/journald.conf:
SystemMaxUse=500M
Then run sudo systemctl restart systemd-journald. The journal stays useful at that size for most servers.
Fix 3: clean up log files safely
Look in /var/log for large files with sudo du -sh /var/log/* | sort -h | tail. Old rotated logs ending in .1, .gz or a date can be deleted.
For a log file that a running program is still writing, do not use rm. Deleting an open file does not free the space until the program closes it, which leads straight to Fix 4. Empty it instead:
sudo truncate -s 0 /var/log/myapp/app.log
Then check that logrotate is configured for that application, so the file is rotated and compressed automatically in future.
Fix 4: release space held by deleted files
This is the case that confuses everyone: df says the disk is full, but du adds up to much less. The usual reason is a file that was deleted while a process still had it open. The space stays allocated until that process closes the file or exits.
sudo lsof +L1

The output lists every open file with zero links, meaning it has been deleted. The SIZE/OFF column shows how much space each one is holding, and PID shows which process. Restarting that service, for example sudo systemctl restart nginx, releases the space at once.
If you cannot restart the process, you can empty the deleted file through /proc:
sudo truncate -s 0 /proc/PID/fd/FD
Replace PID and FD with the values from lsof.
Fix 5: fix “no space left on device” when inodes run out
When df -i shows 100% inode use, the problem is millions of small files, not large ones. Find the directory with the most files:
sudo find / -xdev -type f 2>/dev/null | cut -d/ -f2-4 | sort | uniq -c | sort -n | tail -15

Common sources are PHP session folders, mail queues, cache directories and build artefacts. Delete the files that are safe to remove, ideally with the application’s own cleanup tool. You cannot add inodes to an ext4 filesystem after it is created, so if this keeps happening, plan a filesystem with more inodes (or XFS, which allocates them dynamically) next time.
Fix 6: clear package caches and old kernels
Package managers keep downloaded packages, and old kernels pile up in /boot:
| Distro | Clear the cache | Remove unneeded packages and kernels |
|---|---|---|
| Ubuntu, Debian | sudo apt clean |
sudo apt autoremove --purge |
| Fedora, RHEL | sudo dnf clean all |
sudo dnf autoremove |
| Arch | sudo paccache -r (from pacman-contrib) |
sudo pacman -Rns $(pacman -Qdtq) |
A full /boot stops kernel updates with no space left on device partway through, which can leave the package system half-configured. Run autoremove to remove old kernels, but keep the running kernel (uname -r) and at least one previous version.
Fix 7: clean up Docker
Docker stores images, stopped containers, build cache and volumes under /var/lib/docker, and it is one of the most common causes on servers and developer machines. See where the space goes:
docker system df

Then remove what is not in use:
docker system prune # stopped containers, unused networks, dangling images, build cache
docker image prune -a # every image not used by a container
Be careful with docker volume prune, because volumes can hold database data. Container log files also grow without limit by default, a frequent source of no space left on device on Docker hosts. Set a size limit in /etc/docker/daemon.json, using the options in Docker’s json-file logging documentation:
{ "log-driver": "json-file", "log-opts": { "max-size": "50m", "max-file": "3" } }
Fix 8: remove old snapshots and Snap revisions
Snapshots are easy to forget because they live outside the folders you normally look at:
- Snap keeps old revisions of every snap. List them with
snap list --all, remove the ones markeddisabled, and limit them withsudo snap set system refresh.retain=2. - Timeshift and Btrfs snapshots can grow large; open Timeshift or run
sudo btrfs subvolume list /to review them. - LVM snapshots fill up as the original changes;
sudo lvsshows them.
Fix 9: lower the reserved blocks on data disks
ext4 reserves 5% of every filesystem for the root user by default, so the system can still run when users fill the disk. On a 2 TB data disk, that is 100 GB you cannot use. Check it and lower it on data-only filesystems:
sudo tune2fs -l /dev/sdb1 | grep -i "reserved block count"
sudo tune2fs -m 1 /dev/sdb1
Leave the reservation in place on the root filesystem, where it protects the system.
Fix 10: grow the disk
When everything left is genuinely needed, add space. That is the only permanent fix for no space left on device on a disk that is simply too small for its job. On a cloud VM, increase the volume size in the provider’s console first, then extend the partition and the filesystem:
sudo growpart /dev/sda 1
sudo resize2fs /dev/sda1 # ext4
sudo xfs_growfs / # XFS
With LVM, one command extends the logical volume and the filesystem together after you add space to the volume group:
sudo lvextend -r -L +20G /dev/ubuntu-vg/ubuntu-lv
On physical servers, adding a disk and moving large data, such as /var/lib/docker, onto it is often simpler.
Real-world cases and how they were fixed
The same few patterns appear again and again. These are the ones most likely to be behind your “no space left on device” error.
A database server filled with binary logs
MySQL and MariaDB keep binary logs for replication and recovery. If expiry is not configured, they grow until the disk is full and the database stops accepting writes. Check /var/lib/mysql with du, then remove old logs from inside MySQL rather than with rm:
PURGE BINARY LOGS BEFORE NOW() - INTERVAL 3 DAY;
Set binlog_expire_logs_seconds in the MySQL configuration so it does not happen again. PostgreSQL has a similar trap with write-ahead log files when a replication slot falls behind; check pg_replication_slots for inactive slots.
A crashing service flooded the journal
A service that fails and restarts every few seconds can write gigabytes of identical errors to the journal or to syslog in a day. journalctl --disk-usage reveals it, and journalctl -p err --since today | tail shows which unit is responsible. Fix the service first, then vacuum the journal; otherwise it simply fills again.
A web server ran out of inodes
PHP stores each user session as a small file, and if garbage collection is switched off or misconfigured, millions of them accumulate. The disk shows plenty of free gigabytes, df -i shows 100%, and new uploads fail with no space left on device. Deleting old session files with find /var/lib/php/sessions -type f -mmin +1440 -delete and fixing session.gc_probability resolves it.
A Kubernetes node reported DiskPressure
On Kubernetes, nodes fill up with container images and logs. The kubelet marks the node with DiskPressure and starts evicting pods. Image garbage collection normally cleans up automatically, but thresholds may need tuning, and large application logs written inside containers count against the node’s disk. The Docker and log-rotation steps in this guide apply to container runtimes such as containerd too, using crictl rmi --prune instead of the docker commands.
Repair the damage after a full disk
Freeing space is only half of the job. Programs that tried to write while the disk was full may have left things half-finished:
- If
aptordpkgwas interrupted, runsudo dpkg --configure -a, thensudo apt -f installto finish the job. - On Fedora and RHEL, run
sudo dnf checkand reinstall any package it reports as broken. - Databases usually recover on restart, but check their logs for crash recovery messages and run their integrity checks.
- Check
sudo dmesg | grep -i -E "ext4|xfs|error"for filesystem errors. Filesystems handle running out of space cleanly, but any reported error deserves a check at the next maintenance window. - Look for zero-byte configuration files: an editor that saved while the disk was full can leave an empty file behind.
Monitor disk space automatically
The best fix for no space left on device is never seeing it. Even a basic alert helps:
#!/bin/sh
# /etc/cron.hourly/disk-alert
df -P -x tmpfs -x devtmpfs | awk 'NR>1 && $5+0 >= 80 {print $6" is "$5" full"}' |
mail -E -s "Disk space warning on $(hostname)" admin@example.com
For more than a few servers, use a monitoring tool. Prometheus with node_exporter, Netdata, Zabbix and every cloud provider’s monitoring service can alert on both disk space and inode use. Alert at 80% so there is time to react, and again at 90% for urgency. Predictive alerts, which warn when a disk will fill within a day at its current rate, catch runaway logs that a fixed threshold would miss.
Desktop Linux: the usual space hogs
On a laptop or desktop, “no space left on device” usually comes from your home folder rather than from system logs. These are the places to check first:
| Location | What builds up | How to clean it |
|---|---|---|
~/.cache |
browser and app caches | close the apps, then delete the contents |
~/.local/share/Trash |
files you deleted in the file manager | empty the Bin or Trash |
| Flatpak runtimes | old runtimes no app uses | flatpak uninstall --unused |
~/.local/share/Steam |
games you no longer play | uninstall them from Steam |
| Virtual machine images | GNOME Boxes, VirtualBox and QEMU disks | delete VMs you no longer need |
~/Downloads |
installers and archives | sort by size and remove the large ones |
The file manager’s “Properties” view and tools like Disk Usage Analyzer (Baobab on GNOME, Filelight on KDE) give the same information as ncdu with a graphical map, which is easier for occasional users.
What not to delete
When a disk is full and you are in a hurry, it is tempting to delete anything large. Some folders will break the system or lose data if you remove them by hand:
/usr,/etc,/liband/bin: the operating system itself./var/lib/dpkg,/var/lib/rpmand/var/lib/pacman: the package databases; deleting them makes your package manager forget what is installed./var/lib/mysqlor/var/lib/postgresql: live database files; use the database’s own tools to remove old data./var/lib/docker/overlay2: container layers; usedockercommands instead, or you will corrupt Docker’s state.- The running kernel in
/boot: checkuname -rbefore you remove any kernel.
If you are unsure whether a folder is safe to clear, move it to another disk first, test that everything still works, and delete it later.
Cloud servers and virtual machines
On cloud VMs, running out of disk is common because default root volumes are small, often 8 to 30 GB. The good news is that every major provider lets you enlarge a disk without stopping the machine:
- Take a snapshot of the volume first, so you can roll back.
- Increase the size in the console or with the provider’s CLI (EBS on AWS, managed disks on Azure, persistent disks on Google Cloud).
- Inside the VM, run
lsblkto confirm the disk now shows the new size. - Extend the partition with
growpartand the filesystem withresize2fsorxfs_growfs, as in Fix 10.
Shrinking a disk is much harder than growing it, so add space in modest steps. On hypervisors such as Proxmox, VMware and Hyper-V the process is the same: enlarge the virtual disk, then extend the partition and filesystem inside the guest.
How much free space should a Linux server keep?
There is no single right number, but a few rules of thumb keep “no space left on device” away:
- Keep at least 15 to 20% free on root and data filesystems, so logs and updates have room.
- On database servers, keep enough free space for the largest table to be rebuilt, which some maintenance tasks require.
- On container hosts, leave room for a full image pull and build at the same time.
- On filesystems with many small files, watch inodes as closely as space.
When the disk is so full you cannot work
On a completely full root filesystem, even tab completion and sudo can fail. Free a little space quickly, then carry on:
- Run
sudo apt cleanorsudo dnf clean all; package caches are safe to remove and often hold hundreds of megabytes. - Vacuum the journal with
sudo journalctl --vacuum-size=200M. - Truncate the largest active log with
truncate -s 0.
That is usually enough to run du, ncdu and the other tools normally.
Prevent no space left on device next time
A full disk is one of the most preventable outages:
| Habit | How |
|---|---|
| Alert before it is full | monitor disk and inode use and alert at 80% |
| Limit the journal | SystemMaxUse in journald.conf |
| Rotate every log | a logrotate rule for each application that writes logs |
| Cap Docker logs | max-size and max-file in daemon.json |
| Keep few old kernels | run apt autoremove or dnf autoremove monthly |
| Separate busy data | give /var/lib/docker or databases their own volume |
On desktops, the same habits help. Mac users fighting a full disk will recognise many of these steps from our guide to System Data on Mac, and Windows administrators can find the equivalent clean-up for failed updates in our Windows Update error guide.
FAQ
Why do I get “no space left on device” when df shows free space?
Either the filesystem has run out of inodes (check with df -i), or a deleted file is still held open by a process (check with sudo lsof +L1). Both look like a full disk to programs.
How do I find what is filling my Linux disk?
Run sudo du -xh --max-depth=1 / | sort -h | tail -20 and repeat in the largest folder, or use ncdu for an interactive view.
What does “no space left on device” mean in Docker builds?
During docker build, it usually means the Docker storage area under /var/lib/docker is full, not your project folder. Run docker system df, then docker builder prune to clear the build cache, which is often the largest item.
Can a full disk damage Linux?
Rarely the filesystem itself, but interrupted package upgrades and database writes can leave software half-updated. Free space first, then repair with dpkg --configure -a or your database’s recovery tools.
Is it safe to delete files in /var/log?
Rotated logs, such as files ending in .gz or .1, are safe to delete. Empty active logs with truncate -s 0 instead of deleting them, so the space is freed immediately.
Does Docker cause “no space left on device”?
Often. Unused images, build cache and container logs under /var/lib/docker can grow to tens of gigabytes. docker system df shows how much you can reclaim, and docker system prune removes it.
How do I fix a full /boot partition?
Remove old kernels with sudo apt autoremove --purge on Ubuntu and Debian, or sudo dnf autoremove on Fedora. Keep the running kernel and one previous version.
Why does df show 95% used and 0 available?
That is the ext4 reserved space at work. The last 5% of the filesystem is kept for the root user, so normal users and services running as other users already see the disk as full.
How do I clear /tmp safely?
Files in /tmp older than a few days are usually safe to remove, and most systems clear it at boot. Check for running programs first with sudo lsof +D /tmp, then delete old files with sudo find /tmp -type f -atime +3 -delete.
Can I increase inodes on an existing filesystem?
Not on ext4. You must delete files or recreate the filesystem with more inodes. XFS and Btrfs allocate inodes dynamically, so they rarely run out.
The ten-minute routine
Most cases of “no space left on device” follow the same path: df -h and df -i to find the problem, du or ncdu to find the folder, then logs, journal, caches and Docker to free the space. Keep lsof +L1 in mind for the puzzling cases, set an alert at 80%, and the next full disk becomes a warning instead of an outage.


