1832653 Members
3053 Online
110043 Solutions
New Discussion

du and df

 
navin
Super Advisor

du and df

Hi,
if i do
df /usr
/ (/dev/vg00/lvol3 ): 320892 blocks 190647 i-nodes

du -sk /usr
417098 /usr

please tell me how the du and df differ and
conversion of blocks,kbs,mbs,gg's.

Thanks

subhashni

Learning ...
4 REPLIES 4
Dave Chamberlin
Trusted Contributor

Re: du and df

du -s gives the number of allocated blocks (512 bytes), du -sk converts into KB, or you can divide the du -s output by two and this is the number of KB. The df command give the number of unallocated 512-byte blocks. You can run df -k to give both free and used space in KB.
S.K. Chan
Honored Contributor

Re: du and df

From "df /usr" output it tells you the number of free blocks available and the number of free inodes available. If you do ..
# bdf -i /usr
and take a look at the "avail" column (which is in KBytes) you'll notice that this is equals to 320892/2 ie 160446. So another way of looking at the "df /usr" output is you got 160446 KBytes left. Also notice "ifree" column matches the free inodes number in the "df /usr" output.

Now the "du -sk /usr" tells you the disk usage of /usr (ie 417098 KBytes). Obviously different from the df/bdf output (from the "used" column).

This is because du reports only the diskspace used by text and executable files. It does not report the space used by fileheaders and underlying disk structures. Typically you would see the output from df/bdf of the "used" column slighty more than the "du -sk" output and can be up to a few MBs difference.
navin
Super Advisor

Re: du and df

Thanks.Also tell me
512 bytes-1 block
1024 bytes - 1 kb
1024 kb - 1 mb
1024 mb - 1gg

i would like to know the cylider and track conversions please.

Thank you very much

Learning ...
Bill Hassell
Honored Contributor

Re: du and df

There is no conversion for track and cylinder, given a file's name. This is extremely complicated because the disks are divided into logical volumes, perhaps striped across multiple disks and controllers, and the filesystem code will allocate the file space in a rather complex system of inodes and pointers. You would need a detailed training course on LVM as well as the VxFS filesystem.

And if you are using a disk array, there is no such concept (at the computer side) of track and cylinder--the array translates the required address (a block number within the logical volume) to some location on a set of disks. And in the case of HP's Autoraid, this location may be moved automatically as the free space changes inside the array.


Bill Hassell, sysadmin