Causes of the No space left on device Error in Linux

04 Oct 2026, 14:43:39
The  No space left on device error is usually perceived as an indication that the disk is completely full. However, on Linux, this error can occur even when  df -h shows enough free space. Possible causes include exhausted inodes, deleted files that are still open, a full separate filesystem, reserved blocks, or filesystem problems.
Let's look at the main causes of this error and a step-by-step troubleshooting procedure.

1. Check Free Space on the Filesystem

First, run:
df -hFor example:
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        80G  65G  11G  86% /

In this case, there are still 11 GB available on the / filesystem.
If free space is available but the application continues to receive  No space left on device, do not immediately start deleting files. Other possible causes should be checked first.
For more detailed information, use:
df -hTThe  -T option additionally shows the filesystem type:
Filesystem      Type  Size  Used Avail Use% Mounted on
/dev/sda1      ext4    80G  65G  11G  86% /
The filesystem type is important because it determines which further checks are relevant (ext4, XFS, Btrfs, tmpfs).

2. Check Inodes

One of the most common causes is exhausted inodes.
An inode is a filesystem structure that contains metadata about files and directories. Each file and directory uses at least one inode.
Therefore, you can have plenty of free disk space but still be unable to create a new file.
Check inode usage:
df -iFor example:
Filesystem      Inodes  IUsed  IFree IUse% Mounted on
/dev/sda1      5242880 5242880 0    100% /
Here, disk space may still be available, but  IFree is 0.
As a result, creating a new file may fail with  No space left on device.
Important: on ext4, the number of inodes is fixed when the filesystem is created. On XFS, inodes are allocated dynamically (the limit is controlled by the  maxpct parameter), while Btrfs does not have a fixed inode count, so  df -i is not very informative on Btrfs.

How to Find the Cause

Inodes usually run out because of a huge number of small files.
Common sources include:
  • /tmp;
  • application caches;
  • PHP sessions;
  • mail queues;
  • log directories;
  • temporary files;
  • Docker containers;
  • website directories.
To get an initial idea of how many files are stored in the main directories:
find /var -xdev -type f | cut -d/ -f1-4 | sort | uniq -c | sort -nFor a specific directory:
find /var/www -xdev -type f | wc -lNote: these commands count file names, not inodes. Hard links can have multiple names referring to the same inode, so the result may differ slightly from the actual inode usage.
If you find a directory containing a large number of unnecessary files, determine which application is creating them before deleting anything.

3. Check for Deleted Files That Are Still Open

Another common situation is:
  1. A large file was deleted.
  2. rm  completed successfully.
  3. df -h  barely changed.
  4. The space is still occupied.
This happens when a process continues to keep the deleted file open. For example, a process may continue writing to a deleted log file.
Check for such files:
lsof +L1Example:
COMMAND  PID  USER  FD  TYPE DEVICE SIZE/OFF NLINK NAME
php-fpm  1234 root  10w REG  8,1    10G    0    /var/log/php.log (deleted)
In this case, the file has already been deleted, but the  php-fpm process is still keeping it open. Until the process closes the file descriptor, the occupied space may remain unavailable.
First, identify the process:
lsof +L1Then determine which service started it:
systemctl status After that, the corresponding service can be restarted properly.
For example:
systemctl restart php-fpmThe service name depends on the specific operating system and installed software.
If restarting the service is not currently possible, as a temporary measure you can truncate the deleted file through the process descriptor. The  PID  and  FD values are taken from the  lsof output. In the example above, they are 1234 and  10:
truncate -s 0 /proc/1234/fd/10The space will be released immediately, while the process can continue writing to the file.
Use this method only if you are certain that the contents of the file are no longer needed.
Do not terminate random processes just to free disk space. First make sure that the process is actually holding an unnecessary deleted file open.

How to Avoid Log File Problems

If a log file has not been deleted and you need to clear it, do not remove it with  rm while the application is writing to it.
Instead, truncate the file:
truncate -s 0 /var/log/app.logThe file will remain in place, while its contents and occupied space will be released immediately.

4. Check Each Filesystem Separately

 df -h  displays information for each mounted filesystem.
For example:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        80G  50G  26G  66% /
/dev/sda2        10G  10G    0  100% /var
In this case, the root filesystem / has free space, but  /var is completely full.
An application trying to write data to  /var will receive:  No space left on device.
Therefore, it is important to use:
df -hTrather than looking only at the available space on  /.
You can also check a specific directory:
df -h /varor:
df -h /tmp

5. Find Directories That Are Using Disk Space

If a filesystem is actually full, determine what is consuming the space.
For example:
du -xh --max-depth=1 /var | sort -hThe output may look like:
500M    /var/cache
1.2G    /var/log
8.5G    /var/lib
12G    /var
You can then go deeper:
du -xh --max-depth=1 /var/lib | sort -hFor the root filesystem:
du -xh --max-depth=1 / | sort -hTo find large files:
find /var -xdev -type f -size +1G -exec ls -lh {} \;This can help identify:
  • old backup files;
  • large log files;
  • database dumps;
  • ISO images;
  • temporary files;
  • archives.
Before deleting a file, always make sure that it is no longer needed.

6. Check  /tmp

The  /tmp directory is actively used by various applications.
Check:
df -h /tmpand:
df -i /tmpIf  /tmp is a separate filesystem, it can become full independently of the free space available on /.
For example:
Filesystem      Size  Used Avail Use% Mounted on
tmpfs          512M  512M    0 100% /tmp
In this case, an application attempting to create a temporary file in  /tmp  will receive:  No space left on device
Other  tmpfs filesystems can become full as well, such as  /dev/shm and  /run.

7. Check Reserved Blocks on ext4

On ext4, 5% of blocks are reserved for root by default. Therefore, a regular user or an application running as a non-root user may receive  No space left on device before  Use% reaches 100%, while root can continue writing data without problems.
Check the reserved blocks:
tune2fs -l /dev/sda1 | grep -iE "block count|reserved block"If the reserved space is excessive, for example on a large data partition rather than a system partition, it can be reduced:
tune2fs -m 1 /dev/sda1Change this setting carefully. On system partitions, reserved blocks help protect the system from completely running out of disk space.

8. Check Quotas

The server may use disk space limits for individual users.
Check the quota:
quota -sDepending on the system configuration, you can also use:
repquota -aThis is especially important if:
  • the filesystem has free space;
  • the error occurs only for one user;
  • other users can create files without problems.
With quotas enabled, a user can reach the configured limit even though the filesystem itself still has free space.
Note that when a quota is exceeded, the application will usually receive  Disk quota exceeded (EDQUOT) rather than  No space left on device.
Exceptions are possible, for example with XFS project quotas. If you see Disk quota exceeded, this is where you should look for the cause.

9. Check Docker

On servers running Docker, a significant amount of space can be consumed by: /var/lib/docker.
Check Docker disk usage:
docker system dfThe command shows how much space is used by:
  • images;
  • containers;
  • local volumes;
  • build cache.
You can also check the directory itself:
du -sh /var/lib/dockerFor cleanup, use Docker's built-in commands.
For example:
docker system pruneThis command removes stopped containers, unused networks, dangling images, and build cache. Volumes are not removed by default. They are removed only with the  --volumes option, which should be used with extreme caution on production servers. 
Before running the command, make sure you understand which objects will be deleted.
It is not recommended to manually delete files from  /var/lib/docker, as this can corrupt Docker's internal state.

10. Check the Filesystem State

If free disk space and inodes are available, but write operations still fail, check system messages.
For the kernel:
dmesg -T | grep -iE "error|fail|ext4|xfs|I/O"Also:
journalctl -k -p errPay attention to messages such as:
  • I/O error
  • EXT4-fs error
  • XFS
  • Remounting filesystem read-only
If the filesystem has switched to read-only mode, the application will receive a different error:  Read-only file system (EROFS)  rather than  No space left on device.
This is a related problem, but it is worth checking because the symptoms — write operations failing — can look similar.
The problem is no longer related to a lack of free disk space.
Possible causes include:
  • filesystem errors;
  • disk problems;
  • RAID problems;
  • controller errors;
  • hardware failures.
In this situation, first determine the cause and only then perform filesystem recovery.

Rare Cases of ENOSPC

For completeness, the error can also occur when a directory becomes full. On ext4,  dmesg may contain a  Directory index full message. ENOSPC can also occur when certain IPC resources are exhausted, such as semaphores or shared memory.
These are rare situations, but they are worth keeping in mind when the standard checks do not reveal the cause.

11. Check the Disk and SMART

If the system logs contain I/O errors, check the disk health.
For a SATA/SAS drive:
smartctl -a /dev/sdaFor NVMe:
smartctl -a /dev/nvme0Here,  /dev/nvme0 is the controller, while  /dev/nvme0n1 is the namespace. Both variants can be used with smartctl.
For NVMe, you can also use:
nvme smart-log /dev/nvme0Pay particular attention to signs of:
  • reallocated sectors;
  • pending sectors;
  • uncorrectable errors;
  • media errors;
  • read/write errors.
On servers with hardware RAID, a standard  smartctl /dev/sda command may not show the actual condition of the physical drives.
Depending on the RAID controller, you may need  storcli,  perccli, or other specialized tools.
For MegaRAID controllers,  smartctl can also be used by specifying the physical drive number N:
smartctl -a -d megaraid,N /dev/sda

12. When  df and  du Show Different Values

Sometimes you may encounter a situation where:
df -hshows, for example:
/dev/sda1  100G  95G  5G  95% /
while  du shows significantly less usage.
For a correct comparison, use the  -x option so that  du does not enter other filesystems:
du -xsh /Without  -x, the command can traverse   /proc,  /sys, and filesystems mounted inside /.
The resulting value cannot be directly compared with df.
One possible reason for the difference is deleted files that are still open by processes.
Check them with:
lsof +L1You should also take into account:
  • other filesystems mounted inside /;
  • special filesystems;
  • bind mounts;
  • Docker storage;
  • hidden mount points — data stored in a directory that was later covered by another mounted filesystem. To see such data, mount the root filesystem again through a bind mount: mount --bind / /mnt/root
Therefore,  du and  df do not always have to show identical values.

13. Quick Troubleshooting Algorithm

When  No space left on device appears, it is recommended to proceed in the following order.
Step 1. Check disk space
df -hStep 2. Check inodes
df -iStep 3. Check filesystems and mount points
df -hTStep 4. Find deleted but open files
lsof +L1Step 5. If a filesystem is full, find large directories
du -xh --max-depth=1 / | sort -hFor  /var:
du -xh --max-depth=1 /var | sort -hStep 6. If there is free space but the error occurs only for regular users on ext4
tune2fs -l /dev/sda1 | grep -i "reserved block"Step 7. Check quotas, especially when  Disk quota exceeded  is reported
quota -sStep 8. If Docker is used
docker system dfStep 9. Check filesystem errors
dmesg -T | grep -iE "error|fail|ext4|xfs|I/O"and:
journalctl -k -p errStep 10. If I/O errors are present, check the disk
smartctl -a /dev/sda

Typical Situations

SituationWhat to check
df -h shows free spacedf -i
df -i  shows 100%Number of files/inodes
A large file was deleted but the space was not releasedlsof +L1
/ has free space but writing failsdf -hT
The error occurs only for one userQuota, reserved blocks (tune2fs)
Disk quota exceededquota -s,
repquota -a
/tmp is fulldf -h /tmp, df -i /tmp
Docker uses a lot of spacedocker system df
There is an I/O errordmesg, journalctl, SMART
Read-only file systemFilesystem and disk status
df shows more used space than dudu -xsh /, open deleted files, mount points

Important Points

The  No space left on device error does not automatically mean that you need to delete files.
Before cleaning the server, determine which resource has actually been exhausted:
  • disk space;
  • inodes;
  • reserved blocks;
  • space on a specific filesystem;
  • Docker storage;
  • or filesystem availability due to disk errors.
It is especially important not to blindly run commands such as:
rm -rf /var/log/*or:
rm -rf /tmp/*on a production server. This can delete required data or cause problems for running applications. In addition, deleting logs that are still held open by an application will not necessarily free the space.
Use truncate -s 0 when you need to clear a file while keeping it in place.

Conclusion

If Linux reports  No space left on device even though free space is available, start by checking:
df -h
df -i
df -hT
lsof +L1
In most cases, these commands help determine whether the disk is actually full, inodes have been exhausted, space is being held by a deleted file, or the problem is related to a specific filesystem.
If free space and inodes are normal, proceed to checking quotas, Docker, system errors, and disk health.
This systematic approach helps identify the cause of the error without unnecessarily deleting files or risking disruption to a production server.

VPS in Bulgaria

Browse Configurations

VPS in the Netherlands

Browse Configurations

Windows SSD Storage VPS

Browse Configurations