public inbox for discuss@lists.illumos.org (since 2011-08)
 help / color / mirror / Atom feed
* [discuss] zfs & trim / zero-out free blocks
@ 2025-01-31 16:47 Enrico Weigelt, metux IT consult
  2025-02-01  0:08 ` Till Wegmueller
  2025-02-01 18:44 ` Bill Sommerfeld via illumos-discuss
  0 siblings, 2 replies; 4+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2025-01-31 16:47 UTC (permalink / raw)
  To: illumos-discuss

Hi folks,


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 ?


thx
--mtx

--
---
Hinweis: unverschlüsselte E-Mails können leicht abgehört und manipuliert
werden ! Für eine vertrauliche Kommunikation senden Sie bitte ihren
GPG/PGP-Schlüssel zu.
---
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info@metux.net -- +49-151-27565287


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [discuss] zfs & trim / zero-out free blocks
  2025-01-31 16:47 [discuss] zfs & trim / zero-out free blocks Enrico Weigelt, metux IT consult
@ 2025-02-01  0:08 ` Till Wegmueller
  2025-02-01 18:44 ` Bill Sommerfeld via illumos-discuss
  1 sibling, 0 replies; 4+ messages in thread
From: Till Wegmueller @ 2025-02-01  0:08 UTC (permalink / raw)
  To: discuss

Hi,

The feature is supported but IMHO deactivated by default as Faulty 
implementations on SSD's where a large concern. Check you Zpool features 
and options for more details. ALso you might need to check that you use 
a virtual disk driver that supports TRIM.

-Till

On 31.01.25 17:47, Enrico Weigelt, metux IT consult wrote:
> Hi folks,
> 
> 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 ?
> 
> thx
> --mtx
> 
> --
> ---
> Hinweis: unverschlüsselte E-Mails können leicht abgehört und manipuliert
> werden ! Für eine vertrauliche Kommunikation senden Sie bitte ihren
> GPG/PGP-Schlüssel zu.
> ---
> Enrico Weigelt, metux IT consult
> Free software and Linux embedded engineering
> info@metux.net -- +49-151-27565287
> 

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [discuss] zfs & trim / zero-out free blocks
  2025-01-31 16:47 [discuss] zfs & trim / zero-out free blocks Enrico Weigelt, metux IT consult
  2025-02-01  0:08 ` Till Wegmueller
@ 2025-02-01 18:44 ` Bill Sommerfeld via illumos-discuss
  2025-02-01 18:59   ` Jason King
  1 sibling, 1 reply; 4+ messages in thread
From: Bill Sommerfeld via illumos-discuss @ 2025-02-01 18:44 UTC (permalink / raw)
  To: discuss

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-Mfd5a7507396e50acca798fc2
Delivery options: https://illumos.topicbox.com/groups/discuss/subscription

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [discuss] zfs & trim / zero-out free blocks
  2025-02-01 18:44 ` Bill Sommerfeld via illumos-discuss
@ 2025-02-01 18:59   ` Jason King
  0 siblings, 0 replies; 4+ messages in thread
From: Jason King @ 2025-02-01 18:59 UTC (permalink / raw)
  To: illumos-discuss

[-- Attachment #1: Type: text/plain, Size: 2130 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 5745 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-02-01 19:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-31 16:47 [discuss] zfs & trim / zero-out free blocks Enrico Weigelt, metux IT consult
2025-02-01  0:08 ` Till Wegmueller
2025-02-01 18:44 ` Bill Sommerfeld via illumos-discuss
2025-02-01 18:59   ` Jason King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).