[CentOS] du vs df size difference

Wed Sep 30 21:09:47 UTC 2009
Peter A <loony at loonybin.org>

Cut'n'paste from a tutorial I'm writing right now:


Check with lsof if there are any very large files that are already deleted but 
are still open by some processes.

# df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/md0              194M   32M  153M  18% /boot
# dd if=/dev/zero of=testfile bs=1024000 count=50
50+0 records in
50+0 records out
51200000 bytes (51 MB) copied, 0.370919 s, 138 MB/s
# df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/md0              194M   81M  104M  44% /boot
# vi testfile

<wait till vi comes up, then crtl-z and bg the process>

# rm testfile
# df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/md0              194M   81M  104M  44% /boot

< quit vi>

# df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/md0              194M   32M  153M  18% /boot

Also verify that your fs doesn't have a insane root reserved space set.
# df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/md0              194M   32M  153M  18% /boot
# tune2fs -m 50 /dev/md0
tune2fs 1.41.4 (27-Jan-2009)
Setting reserved blocks percentage to 50% (102368 blocks)
# df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/md0              194M   32M   63M  34% /boot


THere are of course other reasons but those two are a common problem.

Peter.

On Wednesday 30 September 2009 16:59:25 Ryan Pugatch wrote:
> Hi all,
> 
> Curious issue.. looking in to how much disk space is being used on a
> machine (CentOS 5.3).  When I compare the output of du vs df, I am
> seeing a 12GB difference with du saying 8G used and df saying 20G used.
> 
> # du -hcx /
> 8.0G    total
> 
> # df -h /
> Filesystem            Size  Used Avail Use% Mounted on
> /dev/xvda3             22G   20G  637M  97% /
> 
> I recognize that in most cases du and df are not going to report the
> same but I am concerned about having a 12GB disparity.  Does anyone have
> any thoughts about this or reason as to why there is a big difference?
> I have read a few articles online about it and none have really shown
> such a large difference.
> 
> Thanks
> 
> 
> 
> Ryan Pugatch
> Systems Administrator, TripAdvisor
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
>