[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: df/du shows big difference of used space



On Wed, Sep 9, 2009 at 9:56 AM, niclasw<niclaswmail@gmail.com> wrote:
> I have a 1500G hard drive, encrypted.
> Different commands shows different usage:
>
> As root, from root directory:
> df -m
> Filesystem           1M-blocks      Used         Available     Use% Mounted
> on
> /dev/mapper/d       1390840   1284525    35665          98% /
>
> That is 1284G used of 1391G which would be like 92%!
> Not 98%
> Why does it say 98%

Traditionally, 5% of every file system is reserved for root to do with
as it pleases.  In some filesystem (particularly older ones), all
sorts of things could go wonky whenever the system got 100% full.

Depending on the filesystem you're using, you can view or change that
reservation, though you may not really want to.

> du -sh *
> adds up to about 933G
>
> So the question is why the big difference of used space between df and du
>
> du shows 933G used
> df shows 1284G used
>
> Can anyone explain the big difference, 350G, of used disk space between du
> and df commands?

Two things.

First, your du -sh * misses . files/directories.  Depending on what's
going on, that could be significant.  I always use [du -sh .] myself.
Well, strictly speaking, the . isn't necessary (at least with GNU df,
not sure about others any more), but my fingers have been using that
for years and it's ingrained.

Second, on unix-like systems, it's possible to have a file open and
deleted.  It's common to do that with temp files, for instance.   It
could be that some process is running that still has a large file
open, but there's no corresponding file name to find for du to find
and account for, but df knows is still taking up space.

Tools like lsof may help in cases like that.  It has options to show
deleted files.  Though, personally, I tend to do something like:
ls -l /proc/*/fd/* | grep deleted

Mostly, because I learned that before lsof was written and I've never
really bothered to learn the ins and outs of lsof.

mrc


Reply to: