From: David Brown on
Doug Freyburger wrote:
> David Brown wrote:
>> bzaman wrote:
>>
>>> Surprisingly , the du command in my desktop is showing more disk usage
>>> than df . I came across systems where df command shows more disk usage
>>> than du because df includes metadata information about partition and
>>> also considers disk space consumed by files which are removed but not
>>> yet released by some process .
>
> This is extremely common.
>
>>> Can somebody explain why this discrepancy in df and du results .
>> If you've got lots of sparse files, they will show up in the du disk
>> usage, but not on the df for disk free.
>>
>> You'd also get discrepancies if you have other file systems mounted
>> within these trees - they count for du but not for df.
>
> Listing at handful of reasons and explaining why they happen is a
> standard interview question for anyone claiming to be intermediate or
> more in skill and knowledge - Understanding inodes is on the SAGE scale
> for intermediate.
>
> Additional reasons include use of hard links.

I thought of that one too - but hard links are only counted once by du
unless you use the -l switch.
From: unruh on
On 2010-04-29, bzaman <bzaman.laskar(a)gmail.com> wrote:
> Hi ,
>
> Surprisingly , the du command in my desktop is showing more disk usage
> than df . I came across systems where df command shows more disk usage
> than du because df includes metadata information about partition and
> also considers disk space consumed by files which are removed but not
> yet released by some process .
>
>=====
> $ sudo du -sh /
> 13G /
> $ sudo df -h /
> Filesystem Size Used Avail Use% Mounted on
> /dev/md0 9.5G 8.1G 903M 91% /
> ---
> $ sudo df -h /usr/
> Filesystem Size Used Avail Use% Mounted on
> /dev/sda5 8.6G 4.6G 3.6G 56% /usr
> $ sudo du -sh /usr/
> 5.0G /usr/

Sparse files? du uses the size in the directories to add up the total
used. A sparse file may show a size of 2GB but only consume 1K of the
disk space.


>======
>
>
> Can somebody explain why this discrepancy in df and du results .
>
>
> Thanks in Advance
> Badiuzzaman
>
From: Lew Pitcher on
On April 29, 2010 14:18, in comp.os.linux.setup,
unruh(a)wormhole.physics.ubc.ca wrote:

> On 2010-04-29, bzaman <bzaman.laskar(a)gmail.com> wrote:
>> Hi ,
>>
>> Surprisingly , the du command in my desktop is showing more disk usage
>> than df . I came across systems where df command shows more disk usage
>> than du because df includes metadata information about partition and
>> also considers disk space consumed by files which are removed but not
>> yet released by some process .
>>
>>=====
>> $ sudo du -sh /
>> 13G /
>> $ sudo df -h /
>> Filesystem Size Used Avail Use% Mounted on
>> /dev/md0 9.5G 8.1G 903M 91% /
>> ---
>> $ sudo df -h /usr/
>> Filesystem Size Used Avail Use% Mounted on
>> /dev/sda5 8.6G 4.6G 3.6G 56% /usr
>> $ sudo du -sh /usr/
>> 5.0G /usr/
>
> Sparse files? du uses the size in the directories to add up the total
> used. A sparse file may show a size of 2GB but only consume 1K of the
> disk space.

Also

1) du includes filespace "reserved" for root, but df doesn't
2) du doesnt include the space in "deleted" files (files without inodes)
but df does


>>======
>>
>>
>> Can somebody explain why this discrepancy in df and du results .
>>
>>
>> Thanks in Advance
>> Badiuzzaman
>>

--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
Me: http://pitcher.digitalfreehold.ca/ | Just Linux: http://justlinux.ca/
---------- Slackware - Because I know what I'm doing. ------


From: Lew Pitcher on
On April 29, 2010 15:47, in comp.os.linux.setup, lpitcher(a)teksavvy.com
wrote:

> On April 29, 2010 14:18, in comp.os.linux.setup,
> unruh(a)wormhole.physics.ubc.ca wrote:
>
>> On 2010-04-29, bzaman <bzaman.laskar(a)gmail.com> wrote:
>>> Hi ,
>>>
>>> Surprisingly , the du command in my desktop is showing more disk usage
>>> than df . I came across systems where df command shows more disk usage
>>> than du because df includes metadata information about partition and
>>> also considers disk space consumed by files which are removed but not
>>> yet released by some process .
>>>
>>>=====
>>> $ sudo du -sh /
>>> 13G /
>>> $ sudo df -h /
>>> Filesystem Size Used Avail Use% Mounted on
>>> /dev/md0 9.5G 8.1G 903M 91% /
>>> ---
>>> $ sudo df -h /usr/
>>> Filesystem Size Used Avail Use% Mounted on
>>> /dev/sda5 8.6G 4.6G 3.6G 56% /usr
>>> $ sudo du -sh /usr/
>>> 5.0G /usr/
>>
>> Sparse files? du uses the size in the directories to add up the total
>> used. A sparse file may show a size of 2GB but only consume 1K of the
>> disk space.
>
> Also
>
> 1) du includes filespace "reserved" for root, but df doesn't
> 2) du doesnt include the space in "deleted" files (files without inodes)
> but df does

3) du accounts for used filespace at a byte-level (filesize), while df
accounts for used filespace at a block level

>>>======
>>>
>>>
>>> Can somebody explain why this discrepancy in df and du results .
>>>
>>>
>>> Thanks in Advance
>>> Badiuzzaman
>>>
>

--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
Me: http://pitcher.digitalfreehold.ca/ | Just Linux: http://justlinux.ca/
---------- Slackware - Because I know what I'm doing. ------


From: Robert Nichols on
On 04/29/2010 06:17 AM, bzaman wrote:
> Hi ,
>
> Surprisingly , the du command in my desktop is showing more disk usage
> than df . I came across systems where df command shows more disk usage
> than du because df includes metadata information about partition and
> also considers disk space consumed by files which are removed but not
> yet released by some process .
>
> =====
> $ sudo du -sh /
> 13G /
> $ sudo df -h /
> Filesystem Size Used Avail Use% Mounted on
> /dev/md0 9.5G 8.1G 903M 91% /
> ---
> $ sudo df -h /usr/
> Filesystem Size Used Avail Use% Mounted on
> /dev/sda5 8.6G 4.6G 3.6G 56% /usr
> $ sudo du -sh /usr/
> 5.0G /usr/
> ======

Try it again, this time passing the "-x" option to 'du' so that it
won't descend into mount points that it encounters.

--
Bob Nichols AT comcast.net I am "RNichols42"