« Back to all recent discussions

NAS326 du is showing less used than df

HaraldHarald Posts: 1
edited September 12 in Questions
My NAS326 is almost full. df indicates 3.4T used from 3.6T, but du indicates 1.4T used. Why the difference?


#NAS_Sep_2019

Answers

  • lodiabailodiabai Posts: 59  Warrior Member
    Basically, df reads the superblock only and trusts it completely. du reads each object and sums them up.

    Also, a running process can keep a deleted file open. This means the space will still be reserved and seen by df, but since du will no longer see a reference to that file in the directory tree, it cannot see those reserved blocks.
  • eozrocwdeozrocwd Posts: 20  Junior Member
    edited September 12
    The du command only calculates the space occupied by the file.
    The du command only calculates the storage space occupied by files that can be accessed. There are two cases that the du command does not calculate the space that has been allocated to the file.
    Case 1:
    The file is hidden. For example, if a file is stored in the /hola directory and then the file system is installed in the /hola directory, the du command will not calculate the storage space occupied by the files in the /hola directory.
    Case 2:
    The file was opened by another application and the file was deleted. In this case, the storage space occupied by the file will remain in the assigned state until all access to this file is closed. Since there is no relevant record for this file in the directory, the du command will not calculate the allocated space of this file, however the df command will calculate this part of the allocated space.
Sign In or Register to comment.