[PVE-User] sparse and compression

Andreas Herrmann andreas at mx20.org
Mon Dec 11 14:16:38 CET 2017

Hi Migual,

first at all: man zfs!

On 11.12.2017 13:40, Miguel González wrote:
>  Is it advisable to use sparse on ZFS pools performance wise? And
> compression? Which kind of compression?

Sparse or not doesn't matter on SSDs. I would use compression because of less
r/w to the disc and modern CPUs can handle lz4 quite well.

Also keep in mind: A sparse volume only stays sparse if trim/discard is used!

volblocksize is important: ZFS is using 8k as default. For ZFS filesystem a
recordsize of 128K is used.

Some older test:
zpool/vm-zvols/bsize_1k    written               10.3G
zpool/vm-zvols/bsize_1k    logicalused           1.82G
zpool/vm-zvols/bsize_4k    written               2.60G
zpool/vm-zvols/bsize_4k    logicalused           1.76G
zpool/vm-zvols/bsize_8k    written               2.60G
zpool/vm-zvols/bsize_8k    logicalused           1.78G
zpool/vm-zvols/bsize_16k   written               1.87G
zpool/vm-zvols/bsize_16k   logicalused           1.70G
zpool/vm-zvols/bsize_32k   written               1.87G
zpool/vm-zvols/bsize_32k   logicalused           1.71G
zpool/vm-zvols/bsize_64k   written               1.72G
zpool/vm-zvols/bsize_64k   logicalused           1.72G
zpool/vm-zvols/bsize_128k  written               1.75G
zpool/vm-zvols/bsize_128k  logicalused           1.75G

>  Can I change a zpool to sparse on the fly or do I need to turn off all
> VMs before doing so?

No, sparse or not is set at creation.

>  Why a virtual disk shows as 60G when originally It was 36 Gb in raw format?
>  NAME                       USED  AVAIL  REFER  MOUNTPOINT
>  rpool/data/vm-102-disk-1  60.0G  51.3G  20.9G  -

Because of blocksizes. Check zfs get all and read theory about ZFS.

Here's an example for a non-sparse 50GB Volume for a VM:

zpool/vm-zvols/foobar      51.6G  2.19T  34.6G  -
zpool/vm-zvols/foobar  used                  51.6G
zpool/vm-zvols/foobar  referenced            34.6G
zpool/vm-zvols/foobar  compressratio         1.02x
zpool/vm-zvols/foobar  volsize               50G
zpool/vm-zvols/foobar  volblocksize          8K
zpool/vm-zvols/foobar  compression           lz4
zpool/vm-zvols/foobar  refreservation        51.6G
zpool/vm-zvols/foobar  usedbydataset         34.6G
zpool/vm-zvols/foobar  usedbyrefreservation  17.0G
zpool/vm-zvols/foobar  refcompressratio      1.02x
zpool/vm-zvols/foobar  written               34.6G
zpool/vm-zvols/foobar  logicalused           24.2G
zpool/vm-zvols/foobar  logicalreferenced     24.2G


More information about the pve-user mailing list