Middle
Why does df show no space, but du shows that space should be available?
sobes.tech AI
Answer from AI
The df command shows free space at the filesystem level, while du shows the size of files and directories visible in the current directory.
Reasons why df might show no free space, but du shows available space:
- Deleted but open files: If a file was deleted from the directory but a process still has it open,
duwill not see it, butdfwill account for the space used. - Files outside the visible directory:
duonly counts the specified directory, whiledfconsiders the entire filesystem. - Hidden or mounted directories: If there are mount points or hidden files,
dumight not include them.
Example: if a process writes to a log that was later deleted, the space for that file won't be freed until the process closes the descriptor.
To find such files, you can use lsof:
lsof +L1
This will show open deleted files that are occupying space.