From: bzaman on
On Apr 30, 5:52 am, Robert Nichols
<SEE_SIGNAT...(a)localhost.localdomain.invalid> wrote:
> 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"

Thanks . Tried with the -x option , '/' directory space utilization
report looks almost same for both du and df .

=====
zamanb(a)shopfrobsoon-dr ~]$ sudo df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/md0 9.5G 8.1G 902M 91% /
[zamanb(a)shopfrobsoon-dr ~]$ sudo du -shx /
8.0G /
====


For , /usr partition , the difference is much less now .

===
[zamanb(a)shopfrobsoon-dr ~]$ sudo du -shx /usr/
Password:
5.0G /usr/
[zamanb(a)shopfrobsoon-dr ~]$ sudo df -h /usr/
Filesystem Size Used Avail Use% Mounted on
/dev/sda5 8.6G 4.6G 3.6G 56% /usr
===

--Bz
From: Robert Nichols on
On 04/29/2010 10:44 PM, bzaman wrote:
> On Apr 30, 5:52 am, Robert Nichols
> <SEE_SIGNAT...(a)localhost.localdomain.invalid> wrote:
>> 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"
>
> Thanks . Tried with the -x option , '/' directory space utilization
> report looks almost same for both du and df .
>
> =====
> zamanb(a)shopfrobsoon-dr ~]$ sudo df -h /
> Filesystem Size Used Avail Use% Mounted on
> /dev/md0 9.5G 8.1G 902M 91% /
> [zamanb(a)shopfrobsoon-dr ~]$ sudo du -shx /
> 8.0G /
> ====
>
>
> For , /usr partition , the difference is much less now .
>
> ===
> [zamanb(a)shopfrobsoon-dr ~]$ sudo du -shx /usr/
> Password:
> 5.0G /usr/
> [zamanb(a)shopfrobsoon-dr ~]$ sudo df -h /usr/
> Filesystem Size Used Avail Use% Mounted on
> /dev/sda5 8.6G 4.6G 3.6G 56% /usr
> ===

That 0.4G difference for /usr sounds like the space allocated for the
resize inode (inode 7), which 'df' takes into account. Run

tune2fs -l /dev/sda5 | grep features

and see if "resize_inode" appears in the list. It would appear that
your root filesystem was built without that feature. You can also
run:

debugfs /dev/sda5

and type "stat <7>" at the "debugfs:" prompt. Near the top of
the output you should see something like:

Links: 1 Blockcount: 106088

Multiply that block count by the FS block size (probably 4096) to
find the space used.

Note: Running 'debugfs' that way is safe. As long as you don't run
it with the "-w" option it will never write to the filesystem.

--
Bob Nichols AT comcast.net I am "RNichols42"
From: Matt Giwer on
On 04/29/2010 07: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/
> ======

> Can somebody explain why this discrepancy in df and du results .

Formatting defaults to reserving space for su use. Do not use sudo unless you
are interested in that reserved space. Why do you do that in the first place?

If the size of the disk is 1 and du is X then df is 1-X and with rounding
they cannot add up to 1 with the -h option. If you output sectors it should
only be off by one sector because of the X and 1-X results.

Practical matters.

If it is just a generic storage disc then what you add will exactly track a
decrease in df in a non-su case. I have never played with the sudo thing but
as root I get the same as a user. It is not clear exactly what you are getting
with your options. KISS. Use only du -h and df -h. They work and have only the
X and 1-X difference.

There are some marginal gains you can get if a file increased incrementally
over many write operations by copying it to another file. The copy-to file
should be slightly smaller. Then rm the old and mv the new to the old name.
Generally if you are down to playing games like this you need to buy a new
drive. They are CHEAP! these days. Do it.

Given the sizes you report you are nursing a 16bit system far beyond the time
it deserves to be put out of its misery and given a decent burial. Do the
honorable thing.

--
"The werewolf ate my homework," declared the young Dr. Frankenstein.
-- The Iron Webmaster, 4263
http://www.haaretz.com What is Israel really like? http://www.jpost.com a7
Tue May 11 05:51:17 EDT 2010
From: unruh on
On 2010-05-11, Matt Giwer <jull43(a)tampabay.rr.com> wrote:
> On 04/29/2010 07: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/
>> ======
>
>> Can somebody explain why this discrepancy in df and du results .
>
> Formatting defaults to reserving space for su use. Do not use sudo unless you
> are interested in that reserved space. Why do you do that in the first place?

No idea what you mean. He is asking for the ouput of du and df, not
actually using that file space. df reports the same for everyone. du
will have trouble if a directory does not read/search permission for the
user running du.

>
> If the size of the disk is 1 and du is X then df is 1-X and with rounding
> they cannot add up to 1 with the -h option. If you output sectors it should
> only be off by one sector because of the X and 1-X results.

No Not if there are sparse files.
From
http://administratosphere.wordpress.com/2008/05/23/sparse-files-what-why-and-how/
"Sparse files are basically just like any other file except that blocks
that only contain zeros (i.e., nothing) are not actually stored on disk.
This means you can have an apparently 16G file ? with 16G of ?data? ?
only taking up 1G of space on disk"

Thus du will report all 16GB, while df will report 1GB.
>
From: Robert Nichols on
On 05/11/2010 09:46 AM, unruh wrote:
> From
> http://administratosphere.wordpress.com/2008/05/23/sparse-files-what-why-and-how/
> "Sparse files are basically just like any other file except that blocks
> that only contain zeros (i.e., nothing) are not actually stored on disk.
> This means you can have an apparently 16G file ? with 16G of ?data? ?
> only taking up 1G of space on disk"
>
> Thus du will report all 16GB, while df will report 1GB.

No, 'du' will report 1GB unless you use the "--apparent-size" option.

$ dd if=/dev/zero of=junk bs=1k seek=100000 count=1
1+0 records in
1+0 records out
1024 bytes (1.0 kB) copied, 0.000105715 s, 9.7 MB/s
$ ls -ls junk
12 -rw-rw-r--. 1 rnichols rnichols 102401024 2010-05-11 21:23 junk
$ du junk
12 junk
$ du --apparent-size junk
100001 junk

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