System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

size of a dir by du -sk and by ll differs !!!!!

SOLVED
Go to solution
Kuntal Gupta
Frequent Advisor

size of a dir by du -sk and by ll differs !!!!!

Observations:

1)the #du -sk /tmp/patch command shows directory size of /tmp/patch is 841000. I think it is in Kb

2) Now after entering into /tmp/patch and issueing the command ll the size (1st line after total) is 1359744. I think it is the Block no.

3)fstyp command shows the Block size is 8192.
I think it is in Byte.

If my understanding is right the du -sk should reflect the no coming by ' blocks by ll command X block size by fstype, i.e 135977 X 8). If it is so, there is huge difference between the o/p of both the commands

The capture is here,,,

uert1>pwd
/
uert1>fstyp -v /dev/vx/dsk/rootdg/tmpvol
vxfs
version: 6
f_bsize: 8192
f_frsize: 8192
f_blocks: 786432
f_bfree: 632042
f_bavail: 627105
f_files: 163136
f_ffree: 157984
f_favail: 157984
f_fsid: 34613437
f_basetype: vxfs
f_namemax: 254
f_magic: a501fcf5
f_featurebits: 0
f_flag: 16
f_fsindex: 9
f_size: 786432
uert1>

uert1>du -sk /tmp/patch
841000 /tmp/patch
uert1>

uert1>cd /tmp/patch
uert1>pwd
/tmp/patch
uert1>

uert1>ll
total 1359744
-rw-r--r-- 1 root sys 25651200 May 15 19:32 DASProvider_B.11.31.1004_HP-UX_B.11.31_IA_PA.depot
-rw-r--r-- 1 root sys 63406080 May 15 19:36 ONCplus_B.11.31.09.01.depot
-rw-r--r-- 1 21164 12753 52723 Mar 20 2008 PHCO_37807
-rw-r--r-- 1 root sys 30720 Mar 18 2008 PHCO_37807.depot
-rw-r--r-- 1 root sys 3692 Mar 19 2008 PHCO_37807.text
-rw-r--r-- 1 21164 12753 19784722 Apr 11 2009 PHCO_38048
.........................
.........................
.........................

Pls clear my confusion...

Regards....

Kuntal
6 REPLIES
Steven Schweda
Honored Contributor

Re: size of a dir by du -sk and by ll differs !!!!!

First:
uname -a

Then:
man ls

Look for "total".

> [...] If it is so, [...]

It's not.

> total 1359744

That's 1359744 512-byte blocks. 679872KB.

> 841000 /tmp/patch

That's still different, but many things are
possible. For example:

dyi $ ls -l
total 5712
-rw-r--r-- 1 root sys 2922037 Nov 18 2009 u6z3_ia64.zip

dyi $ du -ks .
8568 .

"total 5712" is only 2856KB.

But:

dyi $ ls -lA
total 17136
-rw-r--r-- 1 root sys 2922037 Nov 18 2009 .u6z3_ia64.zip
-rw-r--r-- 1 root sys 2922037 Nov 18 2009 .u6z3_ia64_2.zip
-rw-r--r-- 1 root sys 2922037 Nov 18 2009 u6z3_ia64.zip


For a normal user, "ls -l" ("ll") does not
always show all files.

Trust no one, I always say.
James R. Ferguson
Acclaimed Contributor
Solution

Re: size of a dir by du -sk and by ll differs !!!!!

Hi Kuntal:

'ls' and 'du' may indeed report file sizes. In particular, a sparse file will be smaller in size when interrogated with 'du' than with 'ls'. Empty blocks are reported by 'ls' whereas 'du' doesn't count them.

You can see the difference by creating a sparse file. Perhaps the simplest way is:

# dd if=/dev/zero of=mysparsefile bs=1k count=1 seek=5120

Now, compare:

# du mysparsefile
# ls -l mysparsefile

Using 'cp' to copy a sparse file causes the empty blocks to be allocated and is one way of discovering that a file is sparse. Do:

# cp mysparsefile mynonsparsefile

...and compare the 'ls' and 'du' sizes again.

Regards!

...JRF..,
Kuntal Gupta
Frequent Advisor

Re: size of a dir by du -sk and by ll differs !!!!!

my sincere thanks to both of you for clearing my confusion.
Kuntal Gupta
Frequent Advisor

Re: size of a dir by du -sk and by ll differs !!!!!

let us close this
Steven Schweda
Honored Contributor

Re: size of a dir by du -sk and by ll differs !!!!!

> my sincere thanks to both of you for
> clearing my confusion.

And what was the cause of your confusion?

Someone else might read this someday, and he
might like to know what happened (more than
that you're happy now).
James R. Ferguson
Acclaimed Contributor

Re: size of a dir by du -sk and by ll differs !!!!!

Hi:

> my sincere thanks to both of you for clearing my confusion.

If you are happy with the answers you were given, please read the following about how to assign points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33

...JRF...