There was a ZFS trim bug (https://www.illumos.org/issues/15939) you may want to 
confirm is fixed in the specific version of the illumos distro you’re running 
(I didn’t see any specific distro mentioned) and update if not before doing a 
trim on the pool.

It was fixed about 14 months ago, so anything relatively recent is very likely 
to contain the fix (but better to be sure than sorry).



From: Bill Sommerfeld via illumos-discuss <discuss@lists.illumos.org>
Date: Saturday, February 1, 2025 at 12:44 PM
To: discuss@lists.illumos.org <discuss@lists.illumos.org>
Subject: Re: [discuss] zfs & trim / zero-out free blocks
On 1/31/25 08:47, Enrico Weigelt, metux IT consult wrote:
> since I'm running Illumos in VMs (and have to transfer images via web),
> I need to keep the images (usually qcow2) small.
>
> What happens when lots of space is used once later freed again ?
> Does ZFS automatically trim or zero-out those blocks, so the host can
> doesn't need to store them anymore ?
You can start a one-time trim on the pool "rpool" with:

# zpool trim rpool

This runs in background for a bit (how long depends on the size of the
pool and the speed of the storage); you can check status with:

# zpool status -t rpool

You can also turn on auto-trimming:

# zpool set autotrim=on rpool

As Till said some underlying storage doesn't cope well with auto-trim so
use with care.   I've not seen problems with it, and I've seen space
freed up by an Illumos VM guest with virtio disks (hosted on a Illumos
host via bhyve).

Another area where you could potentially save some space in transit is
by dropping the swap zvol in the guest prior to the transfer - stop any
workload, swap -d in the guest, delete the swap zvol, trim the pool,
snapshot it on the host, then bring them back.

                                                - Bill



------------------------------------------
illumos: illumos-discuss
Permalink: 
https://illumos.topicbox.com/groups/discuss/Teb0468dd89a7f69a-Mc982cf0ccb36b7fb9084cb8d
Delivery options: https://illumos.topicbox.com/groups/discuss/subscription

Reply via email to