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