106 views
Возможна ли ситуация, когда `df` показывает заполненный раздел, а `du` — пустую директорию или существенно меньшее использование? Почему?
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 normaldutraversal. - 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.
Also asked at ozon_tech
- What salary range are you currently considering?
- Tell about transactions: what they are and what are the levels of transaction isolation?
- What transaction isolation levels exist in PostgreSQL?
- Tell me about TCP and UDP, what is the difference?
- Please tell me what you are currently doing, what is your area of responsibility, and what tasks you are working on?
Similar questions
- If the first instruction in a Dockerfile is `FROM alpine`, the second is `COPY` of a 1 GB file, and the third is `RUN rm` to delete that file, will the final image be larger or smaller than 1 GB?
- Deleted a large file, but disk space was not freed. Why? How to find and fix it?
- Have you encountered the Load Average metric, and what does it mean?
- What information or metrics are missing to assess the load average?
- Which command shows disk space?