A question about zfs compression and disk usage in VMs

Saahib

Active Member
May 2, 2021
88
3
28
Hi,
If we have zstd or lz4 compression enabled on ZFS, what user of VM will see it ?
For example, if I have created a virtual machine with 40 GB disk space, since compression is there, on actual node it will occupy lesser space but from inside VM, will it report actual usage or it will be compressed usage inside too ?

Or in other way, say I have 40GB VM, a user copies a file a while which is 7GB in size but after compression its 5.5GB, so if a user copies that 7GB file into VM, how much used space will be reported inside VM, will it be 7GB or 5.5GB ?
 
The compression happens in ZFS. Only the host does know that ZFS (and compression) is used. The guest sees a virtual representation of a very normal and stupid block device - a harddisk.

So in your example the guest will see a file 7GB in size.

(Everything else would be strange: the guest would write 7GB but it sees only 5.5GB? When it reads the file back - would it get 7GB or 5.5? This idea just would'nt work...)