Qcow2 images on a ZFS dataset?

I want the qcow2 images in qemu-kvm in desktop virtual manager to be in a ZFS pool. Currently they are in some directory in /var/etc/libvirt/images. This is in ext4 and will be formatted when I reinstall the operating system. I want the OS to be disposable.

What I did was to create a dataset, then create a volume in virtual manager and select the dataset mountpoint as the directory. It’s one directory for all VMs, so if I need to roll back I have to roll back all of them. This is okay.

Am I doing it correctly?

I noticed virtualization software automatically creates various separate datasets for VMs .

Yes, that’s fine.

If you want, you can set your containing dataset to mount wherever your platform already expects the VMs to be. So, if on your system it wants to put them in /var/etc/libvirt/images, you could zfs set mountpoint=/var/etc/libvirt/images poolname/datasetname in order to have the default location in the VM manager be where your dataset actually is.

2 Likes