ZFS DU and DF differ - can`t clean up the disk

Hi!
I have a mail server running FreeBSD with ZFS on root.
So as Xmas clean-up I`ve asked the personnel of the company to clean up theis mailboxes...
They did... But I didn`t see the result in Zabbix graphs so I asked again and they told me they did for the first time...
So I know for sure that there must be several GBs less than before...
For exmaple before cleaning up a folder with mailbox of one guy was like 7GB (du), now it shows 900M(du)... And du shows decreasing in general but df - doesn`t.

What`s wrong and how to clean up the disk for real? (/usr/home )

Code:
# du -sh /usr/home/
106G    /usr/home/

Code:
du -shx /usr/home/
107G    /usr/home/

Code:
# df -H
Filesystem            Size    Used   Avail Capacity  Mounted on
zroot/ROOT/default     34G    6.6G     27G    19%    /
devfs                 1.0k    1.0k      0B   100%    /dev
zroot                  27G     90k     27G     0%    /zroot
zroot/var/tmp          27G     90k     27G     0%    /var/tmp
zroot/var/audit        27G     90k     27G     0%    /var/audit
zroot/var/crash        27G     34M     27G     0%    /var/crash
zroot/usr/src          27G     90k     27G     0%    /usr/src
zroot/var/mail         28G    1.1G     27G     4%    /var/mail
zroot/usr/ports        28G    1.0G     27G     4%    /usr/ports
zroot/tmp              27G    250k     27G     0%    /tmp
zroot/var/log          28G    331M     27G     1%    /var/log
zroot/usr/home        141G    114G     27G    81%    /usr/home
 
Do you have any snapshot?
The same behavior may appear when some files was 'hard linked'. Their deletion may cleanup the folder, but not the partition, because of hardlink.
 
There are lots of reasons for why du and df can disagree. The biggest one is that in ZFS (and many modern file systems), deletion is asynchronous: you delete a file, and the disk space is actually released when the file system feels like it. It usually only feels like it on sunny and warm days, and right now it's rainy and dark, so the space will continue to be used. Does this worry you? If you were sitting on a tropical beach, and your drink had an umbrella in it, then maybe it would worry you enough to do something about it. Seriously, as long as there is enough space to create new files, there's no need to immediately clean up all deleted files; if the file system is nearly full, creating new files can get slower (because now suddenly clean up of deleted ones has to be done synchronously, meaning right-freaking-now), but that's just not a problem for most real world systems.

Next issue, as im said: If you have a snapshot, the file is still needed, to be readable in snapshots. At least in FreeBSD, sparse files and hard links should be counted correctly in du (matching df), unless you use switches to tell du otherwise.
 
  • Thanks
Reactions: a6h
jazzraven, could be that some process(es) have the deleted files held open. Removed but in-use files still consuming space happens with Linux, wouldn't be surprised if it's a *nix behaviour.
 
Back
Top