On 1/7/06, Per Jessen
Listing of a root directory: (shortened)
saturn:/ # l drwxr-xr-x 4 root root 16 Jun 22 2003 media/ drwxr-xr-x 2 root root 1 Jun 22 2003 mnt/ drwxr-xr-x 6 root root 32 Jun 22 2003 opt/ dr-xr-xr-x 137 root root 0 Dec 31 15:27 proc/ -rw-r--r-- 1 root root 529 Dec 11 2003 razor-agent.log drwx------ 11 root root 131072 Jan 7 09:37 root/ drwxr-xr-x 3 root root 4096 Jul 28 2004 sbin/ drwxr-xr-x 4 root root 16 Jun 22 2003 srv/
The output of "du -hsx /*" (also shortened)
saturn:/ # du -hsx /* 0 /media 0 /mnt 313M /opt du: `/proc': No such file or directory 257M /razor-agent.log 1.8M /root 13M /sbin 5.0G /srv 35G /suse
How can "ls" report 529 bytes for razor-agent.log when "du" says 257M ??? (or vice-versa).
These substantially different file sizes result from different
approaches taken by du and ls. While ls displays the number of bytes
the file contains which is essentially the same number you would see
with 'wc -c'. du on the other hand asks the filesystem how many
blocks a file is using instead of querying for its real size. Since
the number of block is the limiting factor when it comes to disk
capacity du is useful to query for used disk space but not to ask for
a file's size.
A filesystem normally uses blocksizes of 512 bytes if not configured
otherwise. Files with less than 512 bytes of size consume a complete
block even if it's only 1 byte of size. A 513 byte file would
therefore consume 2 blocks.
It is very unlikely that du or ls are buggy. However it's interesting
to notice such a big difference. So far I have seen sparse files of
250 megabytes (ls) du reported to be only 8K of size but not vice
versa. Could you please share the results of 'stat razor-agent.log'?
\Steve
--
Steve Graegert