du command doesn't give the right disk usage report

ykchou99

Cadet
Joined
Mar 27, 2023
Messages
2
I use this command to create 100 20MBs files in a NFS share of TrueNAS.
# for i in {1..100}; do dd if=/dev/zero of=bigfile$i bs=1k count=20000; done
each file looks fine:
-rw-r--r--. 1 root root 20M Mar 27 16:10 bigfile1
But du command doesn't report correctly
# du -sh .
59K .

I also copy stuff from xfs to the share, but the TrueNAS share takes much smaller disk space vs. xfs

anyone else has the same issue? any suggestion ?
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611
This is expected behavior. TrueNAS uses ZFS, and ZFS can use compression. TrueNAS also likely enabled seamless, (and lossless), compression by default.

Thus, compressing "/dev/zero" output will compress VERY WELL. The 59KBs is just the directory entry data that describes the compressed data.

I suggest you read up on ZFS & TrueNAS. Their can be a few gotchas if missed following best practices.
 
Top