Why can a file write command fail even if 'df -h' shows free space?
sobes.tech AI
Answer from AI
A command to write a file may fail despite df -h showing free space, for several reasons:
-
User quotas — even if there is free space on the disk, the user may have a quota limit, and cannot write more data.
-
Reserved space for root — in filesystems like ext4, about 5% of space is usually reserved for system needs and the root user. Regular users cannot use this space, so
dfwill show it as free, but writing will fail. -
Inode limitations — the number of available inodes (structures for storing file information) on the disk may run out, preventing new files from being created despite available space.
-
Access rights and locks — the file may be locked or the user may not have write permissions.
-
The filesystem is mounted in read-only mode — then writing is impossible.
Example of checking inodes:
df -i
Thus, free space according to df is not the only factor affecting the success of writing a file.