bhyve About TRIM for bhyve guests

As "FreeBSD 12.2-RELEASE Release Notes" shows:
The virtio_blk(4) driver has been updated to support TRIM. [r365702] (Sponsored by Klara Systems)

Does this only support FreeBSD guests?

On the following guests with virtio-blk+zvol backends, I tested whether the free space can be reclaimed automatically after deleting some files:

1. FreeBSD 12.2R UFS: Yes
2. FreeBSD 12.2R ZFS: Yes
3. CentOS 7.9.2009 XFS: No
4. Windows 10 20H2 NTFS: No
 
Of course, this driver is used by the guest, host-side support works. I'm pretty sure CentOS and Windows can do it as well, but you have to look at documentation there. I got it working on a Windows Server 2016 using RedHat's VirtIO drivers, but I remember I had to issue a few powershell commands to enable it...

edit: Of course, the filesystem must support it as well. ZFS and UFS on FreeBSD do, as does NTFS on Windows (at least in newer versions). No idea about XFS, never used it.
 
For Windows, I just did a bit of research and think I found what I did to get proper TRIM behavior:

1. If you use RedHat's VirtIO drivers, you might need to upgrade them to the latest versions. In my case, I used an older version without TRIM support
2. Enable TRIM with fsutil behavior set DisableDeleteNotify 0
3. Issue a re-TRIM to reclaim space which is already free with Optimize-Volume -DriveLetter C -ReTrim -Verbose

I recommend taking a ZFS snapshot first in case anything goes wrong.
 
Back
Top