virtio does not support trim. You need to change to virtio-scsi.VirtIO
This creates a thick volume. To create a thin volume you need the option -szfs create -V 10G data1/test
# zfs create -V 10G fastzfs/test_full
# zfs create -V 10G -s fastzfs/test_sparse
# zfs list -o name,used,usedbydataset,usedbyrefreservation,logicalused,logicalreferenced,refreservation fastzfs/test_sparse fastzfs/test_full
NAME USED USEDDS USEDREFRESERV LUSED LREFER REFRESERV
fastzfs/test_full 10.3G 64K 10.3G 30K 30K 10.3G
fastzfs/test_sparse 64K 64K 0 30K 30K none
# dd if=/dev/zero of=/dev/zvol/fastzfs/test_full
dd: writing to ‘/dev/zvol/fastzfs/test_full’: No space left on device
20971521+0 records in
20971520+0 records out
10737418240 bytes (11 GB) copied, 23.3931 s, 459 MB/s
# dd if=/dev/zero of=/dev/zvol/fastzfs/test_sparse
dd: writing to ‘/dev/zvol/fastzfs/test_sparse’: No space left on device
20971521+0 records in
20971520+0 records out
10737418240 bytes (11 GB) copied, 30.8197 s, 348 MB/s
# zfs list -o name,used,usedbydataset,usedbyrefreservation,logicalused,logicalreferenced,refreservation fastzfs/test_sparse fastzfs/test_full
NAME USED USEDDS USEDREFRESERV LUSED LREFER REFRESERV
fastzfs/test_full 10.3G 10.1G 241M 10.0G 10.0G 10.3G
fastzfs/test_sparse 10.1G 10.1G 0 10.0G 10.0G none
# zfs create -V 10G fastzfs/test_full
# zfs set compress=on fastzfs/test_full
# zfs create -V 10G -s fastzfs/test_sparse
# zfs set compress=on fastzfs/test_sparse
# zfs list -o name,used,usedbydataset,usedbyrefreservation,logicalused,logicalreferenced,refreservation fastzfs/test_sparse fastzfs/test_full
NAME USED USEDDS USEDREFRESERV LUSED LREFER REFRESERV
fastzfs/test_full 10.3G 64K 10.3G 30K 30K 10.3G
fastzfs/test_sparse 64K 64K 0 30K 30K none
# dd if=/dev/zero of=/dev/zvol/fastzfs/test_full
dd: writing to ‘/dev/zvol/fastzfs/test_full’: No space left on device
20971521+0 records in
20971520+0 records out
10737418240 bytes (11 GB) copied, 21.7149 s, 494 MB/s
1.41s user 20.12s system 99% cpu 21.719s total
# dd if=/dev/zero of=/dev/zvol/fastzfs/test_sparsedd: writing to ‘/dev/zvol/fastzfs/test_sparse’: No space left on device
20971521+0 records in
20971520+0 records out
10737418240 bytes (11 GB) copied, 21.1612 s, 507 MB/s
1.24s user 19.40s system 97% cpu 21.165s total
# zfs list -o name,used,usedbydataset,usedbyrefreservation,logicalused,logicalreferenced,refreservation fastzfs/test_sparse fastzfs/test_full
NAME USED USEDDS USEDREFRESERV LUSED LREFER REFRESERV
fastzfs/test_full 10.3G 64K 10.3G 30K 30K 10.3G
fastzfs/test_sparse 64K 64K 0 30K 30K none
# zfs create -V 10G fastzfs/test_full
# zfs set compress=on fastzfs/test_full
# zfs create -V 10G -s fastzfs/test_sparse
# zfs set compress=on fastzfs/test_sparse
# zfs list -o name,used,usedbydataset,usedbyrefreservation,logicalused,logicalreferenced,refreservation fastzfs/test_sparse fastzfs/test_full
NAME USED USEDDS USEDREFRESERV LUSED LREFER REFRESERV
fastzfs/test_full 10.3G 64K 10.3G 30K 30K 10.3G
fastzfs/test_sparse 64K 64K 0 30K 30K none
# aaaaas=a; for i in {0..24}; do aaaaas="$aaaaas$aaaaas"; done; echo $aaaaas > /dev/zvol/fastzfs/test_sparse
# aaaaas=a; for i in {0..24}; do aaaaas="$aaaaas$aaaaas"; done; echo $aaaaas > /dev/zvol/fastzfs/test_full
nora# zfs list -o name,used,usedbydataset,usedbyrefreservation,logicalused,logicalreferenced,refreservation fastzfs/test_sparse fastzfs/test_full
NAME USED USEDDS USEDREFRESERV LUSED LREFER REFRESERV
fastzfs/test_full 10.3G 336K 10.3G 32.2M 32.2M 10.3G
fastzfs/test_sparse 336K 336K 0 32.2M 32.2M none
# zfs list -o name,used,usedbydataset,usedbyrefreservation,logicalused,logicalreferenced,refreservation fastzfs/test_sparse fastzfs/test_full
NAME USED USEDDS USEDREFRESERV LUSED LREFER REFRESERV
fastzfs/test_full 10.3G 16.2M 10.3G 2.01G 2.01G 10.3G
fastzfs/test_sparse 16.2M 16.2M 0 2.01G 2.01G none