0

For example, we have directory structure:

Root Directory

  • Directory #1
    • Subdirectory #1
    • Subdirectory #2
    • Subdirectory #3
  • Directory #2
  • Directory #3

Now I'm using df -h to check disk usage but:
When I'm in RootDirectory I'm getting spaces for all Directory #N:

[Paul@MyPC /RootDirectory]$ df -h ./*
Filesystem                       Size    Used   Avail Capacity  Mounted on
RootDirectory                    4.7T     33M    4.7T     0%    /mnt/RootDirectory
/RootDirectory/Directory #1      6.9T    2.2T    4.7T    32%    /mnt/RootDirectory/Directory #1
/RootDirectory/Directory #2      100G     10M    100G     0%    /mnt/RootDirectory/Directory #2
/RootDirectory/Directory #3      4.7T    3.6M    4.7T     0%    /mnt/RootDirectory/Directory #3

And it's correct but when I'm in Directory #1 and I trying to get usage of Subdirectory #N I getting three times this parent directory:

[Paul@MyPC /RootDirectory/Directory #1]$ df -h ./*
Filesystem                    Size    Used   Avail Capacity  Mounted on
RootDirectory/Directory #1    6.9T    2.2T    4.7T    32%    /mnt/RootDirectory/Directory #1
RootDirectory/Directory #1    6.9T    2.2T    4.7T    32%    /mnt/RootDirectory/Directory #1
RootDirectory/Directory #1    6.9T    2.2T    4.7T    32%    /mnt/RootDirectory/Directory #1

Can anyone explain why I'm getting this effect?

  • FreeBSD is not Linux. – Rob Jan 17 at 12:17
1

df only shows mount points. When you run it on a directory that contains multiple files or directories, it shows the mount point where that file or directory resides. Once for every file. That's why you get the same mount point multiple times, once for every file of your list that resides on that mount point.

Quote from the man page:

df displays the amount of disk space available on the file system containing each file name argument.

If you want to check how much space a directory uses, the tool you are looking for is du.

  • Thanks, now I undersand this :) du for this case is too slow (too many directories/files in total 7TB) – Paul Jan 4 at 8:39

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.