df and du do not return matching results
This document (000020611) is provided subject to the disclaimer at the end of this document.
Environment
Situation
Resolution
Cause
Examples:
1. Assume the root file system is being examined and it has files inside /subdir1. There may even be further subdirectories below /subdir1, with further files present. However, another (2nd) file system has been mounted over the top of /subdir1. In that condition, "df /" will include the information about the space used within the root file system's original /subdir1. In contrast, du will not be able to see that area and count the usage there, because another file system is overlaying that directory. Depending on the du command given, du may (or may not) walk through the 2nd file system, but regardless of whether du counts the second file system or not, it will return different results than df.
2. du won't count space still occupied by deleted files; df will. This is especially common when an application opens a file and then the application (or something else) deletes it. The file entry will disappear, so du can no longer find it and count it. However, the file is still under the control of the application which has it open, and the space is not released. This practice is often referred to as "delete on last close". Some applications never close certain files until the application is stopped. Large log files are common culprits, but it could be anything.
3. On NFS client mounts, "df" will query the full file system at the NFS Server side for its entire space summary. But "du" will only walk through the portion of the file system which is actually mounted at the client, which is often not the entire file system.
These are only a few examples. There are likely many other scenarios and configurations where df and du cannot be expected to return the same results. The possibilities are too numerous and elusive to reasonably explore all of them.
Additional Information
Disclaimer
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:000020611
- Creation Date: 10-Mar-2022
- Modified Date:26-Apr-2023
-
- SUSE Linux Enterprise Server
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com