xref: /freebsd/sys/contrib/openzfs/man/man8/zpool-trim.8 (revision f1c4c3daccbaf3820f0e2224de53df12fc952fcc)
1.\" SPDX-License-Identifier: CDDL-1.0
2.\"
3.\" CDDL HEADER START
4.\"
5.\" The contents of this file are subject to the terms of the
6.\" Common Development and Distribution License (the "License").
7.\" You may not use this file except in compliance with the License.
8.\"
9.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10.\" or https://opensource.org/licenses/CDDL-1.0.
11.\" See the License for the specific language governing permissions
12.\" and limitations under the License.
13.\"
14.\" When distributing Covered Code, include this CDDL HEADER in each
15.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16.\" If applicable, add the following below this CDDL HEADER, with the
17.\" fields enclosed by brackets "[]" replaced with your own identifying
18.\" information: Portions Copyright [yyyy] [name of copyright owner]
19.\"
20.\" CDDL HEADER END
21.\"
22.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
23.\" Copyright (c) 2012, 2018 by Delphix. All rights reserved.
24.\" Copyright (c) 2012 Cyril Plisko. All Rights Reserved.
25.\" Copyright (c) 2017 Datto Inc.
26.\" Copyright (c) 2018 George Melikov. All Rights Reserved.
27.\" Copyright 2017 Nexenta Systems, Inc.
28.\" Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
29.\" Copyright (c) 2025 Hewlett Packard Enterprise Development LP.
30.\"
31.Dd May 27, 2021
32.Dt ZPOOL-TRIM 8
33.Os
34.
35.Sh NAME
36.Nm zpool-trim
37.Nd initiate TRIM of free space in ZFS storage pool
38.Sh SYNOPSIS
39.Nm zpool
40.Cm trim
41.Op Fl dw
42.Op Fl r Ar rate
43.Op Fl c Ns | Ns Fl s
44.Fl a Ns | Ns Ar pool
45.Oo Ar device Ns Oc Ns …
46.
47.Sh DESCRIPTION
48Initiates an immediate on-demand TRIM operation for all of the free space in
49a pool.
50This operation informs the underlying storage devices of all blocks
51in the pool which are no longer allocated and allows thinly provisioned
52devices to reclaim the space.
53.Pp
54A manual on-demand TRIM operation can be initiated irrespective of the
55.Sy autotrim
56pool property setting.
57See the documentation for the
58.Sy autotrim
59property above for the types of vdev devices which can be trimmed.
60.Bl -tag -width Ds
61.It Fl a , -all
62Perform TRIM operation on
63all
64pools.
65.It Fl d , -secure
66Causes a secure TRIM to be initiated.
67When performing a secure TRIM, the
68device guarantees that data stored on the trimmed blocks has been erased.
69This requires support from the device and is not supported by all SSDs.
70.It Fl r , -rate Ar rate
71Controls the rate at which the TRIM operation progresses.
72Without this
73option TRIM is executed as quickly as possible.
74The rate, expressed in bytes
75per second, is applied on a per-vdev basis and may be set differently for
76each leaf vdev.
77.It Fl c , -cancel
78Cancel trimming on the specified devices, or all eligible devices if none
79are specified.
80If one or more target devices are invalid or are not currently being
81trimmed, the command will fail and no cancellation will occur on any device.
82.It Fl s , -suspend
83Suspend trimming on the specified devices, or all eligible devices if none
84are specified.
85If one or more target devices are invalid or are not currently being
86trimmed, the command will fail and no suspension will occur on any device.
87Trimming can then be resumed by running
88.Nm zpool Cm trim
89with no flags on the relevant target devices.
90.It Fl w , -wait
91Wait until the devices are done being trimmed before returning.
92.El
93.Sh PERIODIC TRIM
94On machines using systemd, trim timers can be enabled on a per-pool basis.
95.Nm weekly
96and
97.Nm monthly
98timer units are provided.
99.Bl -tag -width Ds
100.It Xo
101.Xc
102.Nm systemctl
103.Cm enable
104.Cm zfs-trim-\fIweekly\fB@\fIrpool\fB.timer
105.Cm --now
106.It Xo
107.Xc
108.Nm systemctl
109.Cm enable
110.Cm zfs-trim-\fImonthly\fB@\fIotherpool\fB.timer
111.Cm --now
112.El
113.
114.Sh SEE ALSO
115.Xr systemd.timer 5 ,
116.Xr zpoolprops 7 ,
117.Xr zpool-initialize 8 ,
118.Xr zpool-wait 8
119