Howto set ZFS recordsize attr on storage volume creation?

Is there any way to set some ZFS dataset attributes
for example recordsize
on container/storage volume creation?
Is there an option to assign specific ZFS dataset to storage volume?

regards

OK so we must wait for it

What is the proper order
1.create zfs dataset set recordsize and then lxc create volume
2.or opposite - lxc create volume and zfs set recordsize

quote

Recordsize is mutable, but changing recordsize won’t change the size or layout of any blocks which have already been written to the dataset—only for new blocks as they are written.

I wonder if we choose option order 2 according to above quote we do sth wrong?

regards

LXD will refuse to create a volume if the dataset already exists, so let LXD create it, then zfs set whatever you want.

I see that support for setting ZFS volblocksize has been merged in 4.23, however I can’t find a way to set the value at VM creation time. The zfs.blocksize key doesn’t seem to be an accepted config value:

lxc launch images:ubuntu/focal ubuntu1 --vm -c zfs.blocksize=16K
Creating ubuntu1
Error: Failed instance creation: Failed creating instance record: Unknown configuration key: zfs.blocksize

Any hints?

It’s a storage config key I believe, so would need to be set through lxc storage set.

lxc storage set default volume.zfs.blocksize 64KiB
lxc launch images:ubuntu/focal ubuntu1 --vm
Creating ubuntu1
Error: Failed instance creation: Failed creating instance from image: Invalid value for volume "ubuntu1" option "zfs.blocksize": Blocksize can be change only for filesystem type

So I’m not even sure how this feature is supposed to be used atm.

Also while there are no universally optimal volblocksize values, the current default of 8k is is far from a middle compromise.

I think this is a bug in LXD I will look into. The block size setting should be supportable for VM block volume types too.

I’ve got a provisional fix for this.

Fix is here: