So the normal way to do this goes along the lines of:
zfs create -s -V 200GB pool1/lxd-zvol/backup
mkfs.ext4 /dev/zd16
mount /dev/zd16 /mnt
chown 1000000:1000000 /mnt
umount /mnt
lxc config device add backup data disk path=/data source=/dev/zd16
The chown step is necessary to have the filesystem be owned by root inside the container (you may have to change the uid/gid to match that of the container), at that point the container should perfectly happily write to it.
It works thanks. Uid is 10000 as shown by lxc config show backup (“Hostid”:100000). Other containers also have the same Hostid, is it secured? I mean can other containers access that ZVOL in anyway ?
@stgraber after hours and hours of searching I still cannot figure out how to set mount option for the secondary drive. Is it even possible ? LXC can do it, but can LXD ?