Can somebody explain this? du & ls showing different sizes

Patrick O'Callaghan pocallaghan at gmail.com
Sun Feb 15 23:26:41 UTC 2009


On Sun, 2009-02-15 at 18:47 -0400, Felipe Nunez wrote:
>  
> 
> >Running du -h tells that the file occupies 512M but ls -l tells that
> 
> > the file is a lot smaller. Also I am sure the the cluster size is
> not
> 
> >512M (or am I wrong there?).
> 
>  In order to explain this behavior I did following test:
> 
> $ echo "hello" > hi.txt
> 
> $ ls -l hi.txt
> 
> -rw-r--r-- 1 user group 6 2009-02-15 18:37 download/hi.txt
> 
> (the size of the file is 6 bytes "hello" + '\n' )
> 
> $ du hi.txt
> 
> 4.0K hi.txt
> 
> (the size of the block -cluster is a MicroSoft equivalent term- is
> 4.0K)
> 
> That explains almost all. (Some data may be in memory in disk cache
> and can be some asynchrony with the file system)

That doesn't affect the result shown by 'du'. As far as it's concerned,
the space is allocated and therefore counts.

poc




More information about the fedora-list mailing list