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
On Wed, Sep 30, 2009 at 04:59:25PM -0400, 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.Do this: mount /dev/xvda3 /mnt du -hc /mnt And see if you can find the other 12GB. I usually do: du -mc --max-depth 2 /mnt | sort -n Though I've recently learned: du -hc --max-depth 2 /mnt | sort --human-readable or some such, but that requires a very recent coreutils installation. -- lfr 0/0 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available URL: <http://lists.centos.org/pipermail/centos/attachments/20090930/c2dc9186/attachment.sig>
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 >
Ryan Pugatch wrote:> 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.du won't look at deleted files, while df will. run lsof | grep deleted and see if any files are deleted are still open, space from them will not be freed until the process releases the file handle. nate
On Wed, Sep 30, 2009 at 2:59 PM, Ryan Pugatch <rpug at tripadvisor.com> 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.One of the things I run into are either hidden files or leaked files where a process is still talking to a file but the directory no longer sees it so du doesn't catch it. ls -l /proc/[0-9]*/fd/| grep delete will show those up. Then its a matter if you want to keep that file around or not. also du / did not look for files in / that were starting with a . ls -la / and see if there are hidden directories or files taking up space. Finally sparse files can give odd readings at time.. but that is the least likely reason.> Thanks > > > > Ryan Pugatch > Systems Administrator, TripAdvisor > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos >-- Stephen J Smoogen. Ah, but a man's reach should exceed his grasp. Or what's a heaven for? -- Robert Browning
At Wed, 30 Sep 2009 16:59:25 -0400 CentOS mailing list <centos at centos.org> 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.Somewhere you have an open, but deleted file. Maybe someone deleted a log file and did NOT do a SIGHUP (or restart) of the corresponding deamon? Or some similar weirdness. Some running process is hanging onto a an open file descriptor of a file that has been deleted. Note that some program create 'unnamed' temp files -- opened, then deleted -- as soon as the program exits, the temp file space gets recycled, without the program 'remembering' to delete it, since it is already deleted. This saves having to deal with an exit handler in case the program crashes.> > Thanks > > > > Ryan Pugatch > Systems Administrator, TripAdvisor > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos > >-- Robert Heller -- 978-544-6933 Deepwoods Software -- Download the Model Railroad System http://www.deepsoft.com/ -- Binaries for Linux and MS-Windows heller at deepsoft.com -- http://www.deepsoft.com/ModelRailroadSystem/
Ryan Pugatch wrote:> > 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?Sparse files? -- Florin Andrei http://florin.myip.org/
On Wed, Sep 30, 2009 at 17:59, Ryan Pugatch <rpug at tripadvisor.com> 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.Maybe you have a mount point overlaping big files... du -x will not find them... -- Marcelo "?No ser? acaso que ?sta vida moderna est? teniendo m?s de moderna que de vida?" (Mafalda)
Luciano Rocha wrote:> Do this: > mount /dev/xvda3 /mnt > du -hc /mnt > > And see if you can find the other 12GB. > > I usually do: > du -mc --max-depth 2 /mnt | sort -n > > Though I've recently learned: > du -hc --max-depth 2 /mnt | sort --human-readable or some such, but that > requires a very recent coreutils installation. >That's interesting.. du is showing the same amount as df when I do this. I wonder why.. Ryan
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.I see similar differences even when I: a) Boot from a rescue CD, b) Freshly fsck the file system to be tested, and c) Mount that file system read-only. I suspected the discrepancy might be due to the space used for the ext3 journal, but I also see it on a freshly created ext2 file system: # mount -r /dev/hda8 /mnt/tmp # du -s /mnt/tmp; df /mnt/tmp 20 /mnt/tmp Filesystem 1K-blocks Used Available Use% Mounted on /dev/hda8 13638436 33824 12911812 1% /mnt/tmp So, there's a 33+MB difference on a fresh, empty ext2 file system. Looking at the file system with debugfs, I find inode 7 is a regular file of size 4299210752 and a block count of 67608. That's a huge sparse file. A little research shows that this is the "resize inode" that reserves space for future GDT blocks so that the file system can be expanded in place. -- Bob Nichols "NOSPAM" is really part of my email address. Do NOT delete it.