Re: free space considerations writing bhyve image to a zvol

From: Eric Borisch <eborisch_at_gmail.com>
Date: Thu, 19 Oct 2023 01:32:51 UTC
Be aware that compression of a zvol can be _very_ different from
compression of a file -- zvols must work on volblocksize-d segments to
compress, and are also forced into integer multiples of the underlying
pool's sector size (2**ashift).

Ashift = 12 -> 4k sector size are typical these days, so a zvol with
volblocksize=4k will not compress (save trivial all-0 areas and the like).
With volblocksize=8k, only if an 8k segment reaches 50% reduction can zfs
successfully compress, 25% for 16k volblocksize, etc.

On top of this, raidz setups bring their own allocation size requirements,
which hit harder on small recordsize / volbolcksize settings (which again,
are typically set smaller on zvols).

If you don't need any of the shows-up-as-a-device and more predictable RW
IOPS (operations on the volblocksize won't risk write amplification in the
ZFS layers or require decompressing a larger record) features of zvol, and
are more concerned about compression, leaving the VM's filesystem in a plan
file will (assuming you haven't dialed down recordsize) give you better
compression.

 - Eric

On Wed, Oct 18, 2023 at 8:51 AM void <void@f-m.fm> wrote:

> On Wed, Oct 18, 2023 at 03:42:37PM +0200, Ronald Klop wrote:
> >You can test how much it will compress your linuxvm.img.
> >
> >$ [/tmp] ls -l ./bla.txt
> >-rw-------  1 ronald  wheel  5242880 Oct 18 15:39 ./bla.txt
> >
> >$ [/tmp] lz4 -c ./bla.txt | wc -c
> >  20604
> >
> >
> >So do "lz4 -c linuxvm.img | wc -c" and it will print about the size of
> the zvol you need.
>
> thanks for that. I'm concerned about wrecking the linux vm's
> filesystem internally in this process though. I know it's easier to
> expand than contract; what i don't know is the detail
>
> >NB: What keeps you from just trying to write it to the zvol and see if it
> works?
>
> downtime & space considerations on the system. And curious if people have
> tried similar, and if they can recall the results. Searching hasn't
> come up with a near-enough matching context.
> --
>
>