No ZFS compression on VM disks

valankar

New Member
Aug 10, 2023
7
6
3
I'm trying to understand why there appears to be no compression being done on my VM disks:

Code:
storage_mirrored/vm-101-disk-0                            compressratio         1.00x                                -
storage_mirrored/vm-101-disk-0                            compression           on                                   inherited from storage_mirrored
storage_mirrored/vm-101-disk-0                            refcompressratio      1.00x                                -

Whereas I do see compression on my container volumes:

Code:
storage_mirrored/subvol-102-disk-0                        compressratio         1.91x                                -
storage_mirrored/subvol-102-disk-0                        compression           on                                   inherited from storage_mirrored
storage_mirrored/subvol-102-disk-0                        refcompressratio      1.94x                                -

Is there something special about VM disks that might prevent this?
 
VM storage is based of fixed size blocks. If your volblocksize (for VM block storage) is 4K and your ashift is 12 (=4K) then even compressed blocks use 4K. A volblocksize of 8K requires at least 50% compression, which is rare. Containers use whole files (with a recordsize of 128K by default) and can therefore more often compress enough to fit in less than 32 blocks (128K with ashift 12).
This is not specific to Proxmox and all compressing filesystems based of blocks tend to have this. See https://klarasystems.com/articles/openzfs1-understanding-transparent-compression/ for more details and an example.
 
  • Like
Reactions: Johannes S