huge difference between du and df - no open file descriptors

Matthew Seaman matthew at freebsd.org
Wed Jul 30 13:08:11 UTC 2014


On 07/30/14 13:26, Nils Effenberger wrote:
> du and df are showing signifcantly different values on our storage
> system:
> 
> [root at zhoernchen ~]# df -h /
> Filesystem          Size    Used   Avail Capacity Mounted on  
> /dev/mirror/root    4.8G    4.1G   336M  93%    / 
> [root at zhoernchen ~]# du -shx / 
> 2.3G    /
> 
> root at zhoernchen:~ # gpart show 
> =>      34  97696301  ada0  GPT  (47G)
>         34       128     1  freebsd-boot  (64K)
>        162  10485760     2  freebsd-ufs  (5.0G)
>   10485922  10485760     3  freebsd-zfs  (5.0G)
>   20971682  76724653     4  freebsd-zfs  (37G)
> 
> =>      34  97696301  ada1  GPT  (47G)
>         34       128     1  freebsd-boot  (64K)
>        162  10485760     2  freebsd-ufs  (5.0G)
>   10485922  10485760     3  freebsd-zfs  (5.0G)
>   20971682  76724653     4  freebsd-zfs  (37G)
> 
> (The zfs partitions are zil and l2arc of the zpool on HDDs)
> 
> My first thought was that this was due to open file descriptors but I
> could'nt find anything relevant with fstat.
> To be absolutely shure I rebooted (fortunately the system isn't
> productive yet) but that didn't help either.
> 
> To enshure that I was using fstat correctly (I'm not that familiar with
> FreeBSD) I created a file of ~350MB, opened it with less, deleted it
> while opened, was able to find it with fstat, closed less and found the
> system in following state:
> 
> root at zhoernchen:~ # du -shx /
> 2.2G    /
> root at zhoernchen:~ # df -h /
> Filesystem          Size    Used   Avail Capacity  Mounted on
> /dev/mirror/root    4.8G    4.5G    -13M   100%    /
> 
> Could someone explain this and how I get that fixed?

One other way of using up space in a partition without it showing up in
du(1) is to have files hidden underneath the mount points for other
filesystems.  So you've got a 5GB UFS partition and a ZFS pool somewhere
-- if you have (say) a file /mnt/big-file on the root and then you mount
another filesystem (eg. ZFS) on top of /mnt you'll hide that file from
du(1), but it will still be using space on the root partition and show
up in df(1) output.

The only way to find this sort of thing is to unmount those other
filesystems and look at what exists under the mount point.

You can also use up space invisibly by creating snapshots -- see
mksnap_ffs(8) and snapinfo(8).

	Cheers,

	Matthew


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1014 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20140730/fb8a72c3/attachment.sig>


More information about the freebsd-questions mailing list