ZFS and libvirt
zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
tank 10.9T 2.81T 8.09T - - 0% 25% 1.00x ONLINE -
virsh # pool-define-as --name zfs --source-name tank --type zfs
Pool zfs defined
virsh # pool-start zfs
Pool zfs started
virsh # pool-autostart zfs
Pool zfs marked as autostarted
virsh # pool-list
Name State Autostart
-------------------------------
default active yes
root active yes
tmp active yes
zfs active yes
virsh # pool-info zfs
Name: zfs
UUID: 926e110e-fd90-4866-ae84-8ec2fe4ef01b
State: running
Persistent: yes
Autostart: yes
Capacity: 10.91 TiB
Allocation: 2.81 TiB
Available: 8.10 TiB
virsh #
virsh # vol-create-as --pool zfs --name vol1 --capacity 1G
Vol vol1 created
virsh # vol-create-as --pool zfs--name vol2 --capacity 700M
Vol vol2 created
virsh # vol-list zfs
Name Path
------------------------------------------------------------------------------
vol1 /dev/zvol/tank/vol1
vol2 /dev/zvol/tank/vol2
virsh # vol-delete --pool zfs vol2
Vol vol2 deleted
Let’s upload an image to our new volume:
virsh # vol-upload --pool zfs--vol vol1 --file /tmp/FreeBSD-10.0-RELEASE-amd64-memstick.img
… and download
virsh # vol-download --pool zfs --vol vol1 --file /tmp/zfsfilepool_vol1.img
Note: if you would check e.g. md5 sum of the downloaded files, the result would be different as downloaded file will be of the same size as a volume. However, if you trim zeros, it’ll be the same.
virt-install -n test \
--os-type=Linux \
--os-variant=debian10 \
--ram=2048 --vcpus=2 \
--boot uefi \
--disk pool=zfs,size=64 \
--graphics none \
--console pty,target_type=serial \
--extra-args 'console=ttyS0,115200n8 serial' \
--location 'http://ftp.debian.org/debian/dists/stable/main/installer-amd64/'