[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: how does "du" deal with hard links?



Robert P. J. Day wrote:
  i'm wondering if i should be surprised about something i just
noticed WRT how "du" tries to avoid [re]counting files that it's
already seen via hard links.


  if i check their disk usage individually, i get:

$ for r in git* ; do
du -s $r
done
26340   git
26292   git.local
26292   git.nolinks
$

  but if i use wildcards, notice the difference:

$ du -s git*
26340   git
9672    git.local
26292   git.nolinks
$


  i can see what's happening, i just didn't realize that that's how
"du" operated.  is that deliberate?

I guess so, since du provides the -l option which will count a file's size multiple times if it's hardlinked rather then just counting it the first time it's seen.

As you said it makes sense not to count hardlinked files more than once if you're trying to get a real estimate of disk usage. We'd get very whacky answers on some of our servers based on the number of hardlinks we sometimes use.

Simon.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]