Skip to content
Middle+106 views

Возможна ли ситуация, когда `df` показывает заполненный раздел, а `du` — пустую директорию или существенно меньшее использование? Почему?

Practice

Asked at

AI answer

Yes. df shows overall filesystem block usage, while du sums the usage of files visible in the specified directory tree. They can differ for several reasons:

  • A file is deleted while a process still has it open: it is no longer visible to du, but its blocks are not freed until the process closes the file.
  • Another filesystem is mounted on a directory: content hidden beneath the mount point may be counted by df, but not by a normal du traversal.
  • Space is occupied by filesystem metadata, reserved blocks, or snapshots.
  • Permissions, sparse files, and counting options affect the results.

On Linux, lsof +L1 is often used to find deleted but still-open files; mount points can be checked with findmnt.