I'm a UNIX Sysadmin, specializing in Solaris and Linux. We should ALL know this stuff, but sometimes a trick or tip slips by, so every time I teach someone a neat trick (or someone teaches me a neat trick) it'll get shared here.

Wednesday, January 4, 2017

du vs df differences: the untold story

/dev/mapper/VGsys-LVroot
                       14G   12G  1.7G  88% /
root@SERVER:/> du -hxs /

5.9G    /
root@SERVER:/>

What the hell? why would df report such a different size from du for a filesystem?

Well, there are a few answers, many of them are common.

1) deleted filehandles held open by a process!
That's not the case here.  Server had been rebooted a few times.

2) Sparse files!
Not the case here either.  There are a few sparse files, but nothing anywhere near that big

3) Filesystem corruption!
This is seriously what I thought it was.  But nope.  Filesystem was cherry.

So, do you know what it was?
Two coworkers suggested I remount or bind mount root to another place.
# mount /dev/VGsys/LVroot /mnt2

# df -h /mnt2
                       14G   12G  1.7G  88% /

# du -hxs /mnt2
12G


So, do you know what it was?
There was a subdirectory that had 5g of crap in it that was also a mountpoint.
The du command I ran restricted to one file system, and saw the mountpoint, and ignored anything under it.  Too bad there was actually stuff there.


No comments:

Post a Comment

About Me

My photo
I am currently a Unix Systems Engineer for a cloud-based EMR company. I've been making large, complex systems "go" since 1995. I've worked with Novell and Exchange in the past, and now specialize in Solaris and Linux.