Discard and SSD emulation on internal ZFS-pools

Sep 2, 2024
4
0
1
Lower Austria
Hello

I want to open this thread because all other threads, that I found, did not mention my use-case.

Again, it is about the discard and ssd-emulation option because I don't get it.

My current setup hast two internal zfs pools. Created with Disks -> ZFS -> create: ZFS
One is SSD and the other one is HDD. Now I want to create ubuntu machines on both of them.
Do I need to tick discard or not? In the manual it says, it is about the support on the storage but I don't have "a storage".
There are just some local drives in a zfs-raid. Does this support/need discard?
Does it depend on if my ubuntu machines use ext4 with lvm or without lvm in the machine?

Do I need to activate ssd emulation on real ssds?
 
On a SSD ZFS pool a VM with discard-option enabled works: fstrim -va reports things being done.
On a HDD ZFS pool a VM with discard-option AND ssd-emulate works: fstrim -va reports things done.
Upgraded some machine from 20.04 Ubuntu after which that one stopped working. Have not troubleshooted. YMMV.

edit: Under storage: Thin Provision checked.
 
Last edited:
For trim to work the storage needs to support unmapping of the blocks. Thin provisioning can not work either if the commands are not supported through the stack. Of course you can thin provision the storage if the underlying filesystem supports unmapping the blocks. That is what the ssd emulation is for. If the vm thinks it is on a hdd it mostly will not default to supporting unmaps. I think it can be forced. Either way the "Storage" needs to have thin provisioning enabled to support it. But if you would want to trim a HDD then that will not work. Maybe there are drives (HDD) that support it but I have none. ZFS can free blocks and that will show up in the statistics. If the drive (mostly SSD) supports trim then the intent is relayed through to the drive. Then the freeing of the blocks will happen when trim is run on ZFS.

I am no expert so what I wrote may not be factually entirely correct.

Discard is needed to support the relaying of the intent to unmap the blocks down from the VM.
 
Last edited: