What "No space left on device" means
"No space left on device" is the text Linux prints for the error code ENOSPC. The errno manual lists it under that exact wording, and any program that tries to write to a full filesystem gets it: cp, apt, MySQL, PHP, Docker, even your shell when it tries to save history. You may also see it as Errcode: 28 or errno 28, which is the number Linux gives ENOSPC.
The message is short, but it covers several different problems. A filesystem can run out of data blocks (the normal "disk full"), run out of inodes (the slots that hold one entry per file), refuse writes because the remaining space is reserved for root, or still be holding space for a deleted file a process has open. A few kernel limits that have nothing to do with disk space, such as inotify file watches, report the same error code. The fix depends on which one you have, so diagnose first and delete second.
Step 1: find out which filesystem is full
Run df with human-readable sizes and the filesystem type:
df -hT
Typical output on an Ubuntu 24.04 or 22.04 server looks like this:
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 39G 37G 0 100% /
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/vda15 vfat 105M 6.1M 99M 6% /boot/efi
Read the Mounted on column, not just the first line. The full filesystem may be /, a separate /boot, /var, /tmp or a data volume, and the program that failed was writing to whichever one holds its path. Note that Used plus Avail often adds up to less than Size; on ext4 that gap is the root-only reserve explained in step 5.
Step 2: check inodes as well as space
If df -h shows free space but writes still fail, check inodes. The df manual describes -i as listing inode information instead of block usage:
df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/vda1 2580480 2580480 0 100% /
IUse% at 100% means the filesystem cannot create one more file, however many gigabytes are free. On ext4 the number of inodes is fixed when the filesystem is made: the mke2fs manual explains that it creates one inode for every bytes-per-inode bytes of space and warns that the ratio cannot be changed afterwards. Millions of tiny files, such as PHP session files, cache fragments, mail queue entries or a runaway script writing one file per request, use up inodes long before they use up space.
To find which directory holds them, count inodes per directory with du, which also accepts --inodes:
sudo du --inodes -x / 2>/dev/null | sort -n | tail -20
The last lines are the directories with the most files. Usual suspects are /var/lib/php/sessions, application cache folders under /var/www, /var/spool and node_modules trees. Delete files you can identify as disposable, then fix whatever created them: a missing cleanup cron job, a cache with no expiry, or a mail queue that is retrying forever.
Step 3: find what is using the space
For a normal "disk full", walk down from the full mount point with du. The -x option (--one-file-system) stops it crossing into other filesystems, and --max-depth=1 prints one total per directory:
sudo du -xh --max-depth=1 / 2>/dev/null | sort -h | tail -15
Then repeat on the largest directory, for example sudo du -xh --max-depth=1 /var | sort -h | tail, until you reach the files themselves. To list single large files directly:
sudo find / -xdev -type f -size +500M -exec ls -lh {} + 2>/dev/null
On a web server the space nearly always ends up in one of a few places:
/var/log: application or web server logs that are not rotated, and the systemd journal in/var/log/journal./var/lib/docker: old images, stopped containers, build cache and container logs./var/lib/mysql: database files and, often, binary logs that never expire.- Backup files: a nightly
.tar.gzor.sqldump written to the same disk and never pruned. /var/cache/aptand old kernels under/boot.- Home directories: uploads, core dumps and forgotten copies of a site.
If you are not yet comfortable on the command line, start with our guide on how to SSH into a server; every command here runs in that session.
Step 4: free space safely
Shrink the systemd journal
Check how much the journal uses, then remove old archived entries:
journalctl --disk-usage
sudo journalctl --rotate
sudo journalctl --vacuum-size=200M
The journalctl manual explains that --vacuum-size removes the oldest archived journal files until they fall below the size you give, and does not touch active files. Running --rotate first archives the active files so the vacuum can reach them; the manual also lets you combine the two in one command. --vacuum-time=7d keeps a week of logs instead of a fixed size.
To keep it from growing back, set a cap. By default, journald.conf limits the persistent journal to 10% of the filesystem, capped at 4 GB. On a small root disk that may still be more than you want:
sudo mkdir -p /etc/systemd/journald.conf.d
printf '[Journal]\nSystemMaxUse=500M\n' | sudo tee /etc/systemd/journald.conf.d/size.conf
sudo systemctl restart systemd-journald
Clear package caches and old kernels
sudo apt-get clean
sudo apt autoremove --purge
apt-get clean empties /var/cache/apt/archives, the downloaded .deb files, which apt can fetch again if it needs them. autoremove removes packages that were installed only as dependencies and are no longer needed, which on Ubuntu usually includes older kernel versions (the running kernel is kept). If /boot is a separate small partition and full, this is usually the fix; if apt itself cannot run because the disk is full, free a little space elsewhere first.
Prune Docker
Docker hides a lot of disk use under /var/lib/docker. See the breakdown, then prune:
docker system df
docker system prune
Docker's documentation lists what docker system prune removes: stopped containers, networks not used by a container, dangling images and unused build cache. -a also removes every image not used by a container, and --volumes removes anonymous volumes, so read the confirmation prompt before you agree. Without --volumes no volumes are removed, and the documentation describes --volumes as pruning anonymous volumes, so named volumes, which usually hold databases, should stay; check docker volume ls before you run it anyway. Container logs can also grow without limit; our Docker on Ubuntu guide covers the install, and setting a log size limit for the logging driver keeps them in check.
Rotate and compress application logs
For a single huge log file that a service is still writing to, empty it instead of deleting it:
sudo truncate -s 0 /var/log/myapp/app.log
Then add the file to logrotate (a file under /etc/logrotate.d/) so it is rotated, compressed and expired automatically. For database binary logs, set an expiry in the database configuration rather than deleting the files by hand, because the server keeps an index of them.
Step 5: if df still shows the disk full
Deleted files still held open
The most confusing case: you deleted a 10 GB log, but df still shows 100%, and du totals far less than df says is used. The unlink manual explains why: if any process still has a file open when its last name is removed, the file stays in existence until the last file descriptor referring to it is closed. The space is not freed until then.
List deleted-but-open files:
sudo lsof +L1
Each line shows the process (for example nginx, php-fpm, mysqld or java) and the size it is holding. Restart or reload that service and the space comes back. If you cannot restart it and the file is a log or temporary file you can afford to lose, you can empty it through the process's file descriptor, using the PID and FD number from the lsof output:
sudo truncate -s 0 /proc/<PID>/fd/<FD>
This is why the safe way to clear a live log is truncate, not rm.
The root-only reserve on ext4
ext4 keeps a share of blocks for privileged processes. The mke2fs manual gives the default as 5%, so that root-owned daemons such as the system logger keep working after ordinary users are stopped from writing. df works out Use% from used plus available space only, so it shows 100% as soon as Avail reaches 0, even while reserved blocks remain. If Used is still clearly below Size, or a web app fails while root can still write, you are in that reserve. Check it with:
sudo tune2fs -l /dev/vda1 | grep -i 'reserved block count'
On a large data-only volume you can lower it, for example sudo tune2fs -m 1 /dev/vdb1. Treat that as a short-term measure on the root filesystem: the reserve exists to keep the system recoverable, and the real fix is still to free space or grow the disk.
Files hidden under a mount point
If something wrote to /mnt/data or /backup before the volume was mounted there, those files sit on the root filesystem underneath the mount, where du cannot see them. Bind-mount root somewhere else to look:
sudo mkdir -p /mnt/rootfs
sudo mount --bind / /mnt/rootfs
sudo du -xh --max-depth=1 /mnt/rootfs/mnt /mnt/rootfs/backup
sudo umount /mnt/rootfs
The inotify variant: "System limit for number of file watchers reached"
Sometimes ENOSPC appears with plenty of disk and inodes free, from a file watcher: a Node.js dev server, tail -f, an IDE remote agent or a sync tool. The inotify_add_watch manual lists ENOSPC for the case where the user limit on the total number of inotify watches has been reached. Disk cleanup will not help. Check and raise the limit:
cat /proc/sys/fs/inotify/max_user_watches
echo 'fs.inotify.max_user_watches=524288' | sudo tee /etc/sysctl.d/60-inotify.conf
sudo sysctl --system
Each watch uses a little kernel memory, so raise it to what you need rather than to the largest possible number, and stop watchers from scanning node_modules where you can.
Quick diagnosis table
| What you see | Likely cause | First command | Fix |
|---|---|---|---|
df -h shows 100% | Data blocks used up | sudo du -xh --max-depth=1 / | sort -h | Remove logs, caches, old backups; grow the disk |
df -h has space, df -i shows 100% | Inodes used up by many small files | sudo du --inodes -x / | sort -n | tail | Delete the small files and stop what creates them |
| Avail 0, Used below Size; root can still write | ext4 reserved blocks | sudo tune2fs -l /dev/vda1 | Free space; lower the reserve only on data volumes |
df full but du totals much less | Deleted files still open, or files hidden under a mount | sudo lsof +L1 | Restart the holding service; check under mount points |
| "System limit for number of file watchers reached" | inotify watch limit | cat /proc/sys/fs/inotify/max_user_watches | Raise fs.inotify.max_user_watches |
| "Disk quota exceeded" | Per-user quota (EDQUOT), common on shared hosting | Check usage in your hosting panel | Delete files or move to a larger plan |
| apt fails during kernel install | Small /boot full of old kernels | df -h /boot | sudo apt autoremove --purge |
Common mistakes
- Deleting a live log with
rm. The space stays used until the service restarts. Usetruncate -s 0and set up rotation. - Deleting files under
/var/lib/mysqlor/var/lib/dockerby hand. Both have their own bookkeeping. Use the database's own commands and settings, anddocker system prune. - Running
duwithout-x. It wanders into/proc, network mounts and other disks, and the totals stop matchingdf. - Only checking
df -h. A full inode table looks like a healthy disk until you rundf -i. - Freeing space but not finding the cause. If a log grew 20 GB in a week, it will do it again. Find the writer, and add log rotation, a journal cap or a cleanup cron job.
- Keeping backups on the same disk. They fill it, and they disappear with it. Copy backups off the server and keep only a few local copies.
- Using the database while the disk is full. MySQL and MariaDB can stop or crash when they cannot write. After freeing space, check that the database service is running; our guide to the "Error establishing a database connection" message covers what WordPress shows when it is not.
Growing the disk instead
Sometimes the data is real and simply needs more room. On a virtual server, growing a disk has three layers: the provider enlarges the virtual disk, then you grow the partition and the filesystem inside it:
lsblk
sudo growpart /dev/vda 1
sudo resize2fs /dev/vda1 # ext4
sudo xfs_growfs / # XFS, by mount point
Check that lsblk shows the new size before running the other two. On ext4, the mke2fs manual notes that resizing a filesystem changes the number of inodes to keep the same ratio, so growing the disk also adds inodes.
On a Bigdomainhost KVM VPS you have full root access, and you can grow the disk from the instance view in the control panel without a reboot, up to 2 TB per server, as listed under resizing and limits in our docs. Disks grow but cannot shrink, so add what you need now. Our post on disk resize without a reboot walks through each layer. On cPanel hosting you do not manage the disk yourself; the limit is your account's quota, and the error you see is usually "Disk quota exceeded".
On a Windows server
Windows reports the same condition as "There is not enough space on the disk". Check free space per drive in PowerShell with Get-PSDrive -PSProvider FileSystem, then look for large IIS or application log folders, old installers and temporary files, and use the built-in Disk Cleanup tool for Windows Update leftovers. The ideas carry over: find the biggest folders first, rotate logs, and keep backups off the system drive.
Stuck with a server that will not let you log in to clean up? Message us on WhatsApp at +91 75994 50220 at any time, call during IST working hours, or email support@bigdomainhost.com.
Bigdomainhost wrote this guide with AI assistance and sells the VPS servers it describes. Commands were checked against the Linux man-pages, systemd and Docker documentation on 28 November 2026; output and defaults can differ between versions, so check man df, man du and man journald.conf on your own system.
Sources (checked )
- Linux man-pages project: errno(3): ENOSPC No space left on device
- Linux man-pages project: df(1): -h and -i (inodes)
- Linux man-pages project: du(1): -x, --max-depth and --inodes
- Linux man-pages project: unlink(2): deleted files stay until the last open descriptor closes
- Linux man-pages project: mke2fs(8): bytes-per-inode ratio and the 5% reserved blocks
- systemd (freedesktop.org): journalctl(1): --disk-usage, --rotate and --vacuum-size
- systemd (freedesktop.org): journald.conf(5): SystemMaxUse defaults
- Linux man-pages project: inotify_add_watch(2): ENOSPC when the watch limit is reached
- Docker Docs: docker system prune: what it removes