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

Re: Rsync and different sizes



On Thursday 19 October 2006 23:19, Sturla Holm Hansen wrote:
> Hmm, just wondering, would hardlinks report different sizes too?

Remember a file stored as an hard link.
Definitely yes. du, by default, reports the size of the file on disk.
The size of the file on disk is file dependent on your file system and 
on the block-size you choose when you use mkfs.
To get the apparent size (which is for me the real file size, it's 
called apparent because of sparse file, I guess) you have to use the -b
option.
But remember that the apparent size of directories is still file system 
dependent.

To complicate things the du man page also refers that the apparent size
could be increased by fragmentation and indirect blocks.
I don't think this is true.
It sound strange to me since du uses st_size from stat and st_size
in the SUS is defined: "For regular files, the file size in bytes".
So st_size should be independent from the file system.
The du info manual (for --apparent) also explain:
Print apparent sizes, rather than disk usage.  The apparent size
of a file is the number of bytes reported by `wc -c' on regular
files, or more generally, `ls -l --block-size=1' or `stat --format=%s'.

> Since this is a sync of /var/lib/backuppc which contains a LOT of
> hardlinks this could explain the size-difference....

You really want to say that /var/lib/backuppc contains a lot of files
with hard link count grater than 1.
And you hit another strange behaviour!
The size reported by du isn't absolute! It depends on "how you ask"!

$ ls
$ du -b
6       .
$ mkdir a
$ du -b ./a
6       ./a
$ du -b
6       ./a
20      .
$ mkdir b
$ du -b ./b
6       ./b
$ du -b
6       ./a
6       ./b
34      .
$ echo 'test' > a/test
$ du -b ./a/test
5       ./a/test
$ du -b ./a
22      ./a
$ du -b
22      ./a
6       ./b
50      .
$ ln a/test b/link
$ du -b ./b/link
5       ./b/link
$ du -b ./b
11      ./b
$ du -b
22      ./a
6       ./b
50      .

See that ./b one time is 11 and one time is 6 and realise the real 
meaning of the brief description of du: *estimate* file space usage.

Regards,
Daniele



Reply to: