What the message looks like
cp: cannot create regular file '/var/www/nextcloud/data/upload.tmp': No space left on deviceCommon causes
- All inodes used up by millions of small files (PHP sessions, cache, mail queue, Maildir).
- Deleted but still open files (e.g. logs) keep using space until the process closes them.
- Blocks reserved for root (5% by default on ext4): regular users already see the disk as full.
- A different filesystem is full, e.g.
/tmpon tmpfs or a Docker volume. - A user or group quota is reached.
Check
- Space per filesystem
df -h - Inode usage per filesystem
df -i - Find deleted files that are still open
sudo lsof +L1 - Find directories with the most files
sudo du --inodes -x /var 2>/dev/null | sort -n | tail -n 15 - Show reserved blocks (ext4)
sudo tune2fs -l /dev/sda1 | grep -i 'reserved block count'
Fix
- Delete masses of small files in a targeted way, e.g. old sessions:
find /var/lib/php/sessions -type f -mmin +1440 -delete. - Restart the process holding a deleted file, or truncate it via
: > /proc/<PID>/fd/<FD>. - Configure logrotate properly (
postrotatewith reload orcopytruncate) so open logs are not deleted. - On pure data disks, lower the reservation:
tune2fs -m 1 /dev/sdb1. - Automate cleanup via cron and monitor inode usage.
Typical scenario
A Nextcloud upload fails with 'No space left on device' although df -h still shows 40 percent free. df -i reveals 100 percent of inodes used, caused by millions of tiny PHP session files in a directory that was never cleaned. So run df -i first and look for the directory with the most files before you free disk space.
FAQ
Can I increase the inode count afterwards?
Not on ext4 without reformatting. XFS and Btrfs allocate inodes dynamically. Long term, remove the cause of all the small files.
Why is no space freed after deleting the big log file?
The process still has the file open. The kernel only frees the space after the service is restarted or reloaded – lsof +L1 shows these cases.
Why do df and du show different values?
du adds up visible files, df asks the filesystem. Deleted but still open files, such as a log file after logrotate without a reload, keep occupying space. lsof +L1 lists them.
How do I find the directory eating the inodes?
Count files per directory, for example with find / -xdev -type f | cut -d/ -f2-3 | sort | uniq -c | sort -n. Typical culprits are session directories, mail queues, cache folders and failed backup runs.
Can an ext4 filesystem with free space still be full for users?
Yes. By default ext4 reserves a share of blocks for root. Normal processes get ENOSPC although df shows room for root. tune2fs -l displays the reserved share.