xref: /freebsd/sys/contrib/openzfs/man/man8/zpool-trim.8 (revision fa38579f317d5c2ff2926fab9b12ee6d429bd155)
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.\"
30.Dd May 27, 2021
31.Dt ZPOOL-TRIM 8
32.Os
33.
34.Sh NAME
35.Nm zpool-trim
36.Nd initiate TRIM of free space in ZFS storage pool
37.Sh SYNOPSIS
38.Nm zpool
39.Cm trim
40.Op Fl dw
41.Op Fl r Ar rate
42.Op Fl c Ns | Ns Fl s
43.Ar pool
44.Oo Ar device Ns Oc Ns …
45.
46.Sh DESCRIPTION
47Initiates an immediate on-demand TRIM operation for all of the free space in
48a pool.
49This operation informs the underlying storage devices of all blocks
50in the pool which are no longer allocated and allows thinly provisioned
51devices to reclaim the space.
52.Pp
53A manual on-demand TRIM operation can be initiated irrespective of the
54.Sy autotrim
55pool property setting.
56See the documentation for the
57.Sy autotrim
58property above for the types of vdev devices which can be trimmed.
59.Bl -tag -width Ds
60.It Fl d , -secure
61Causes a secure TRIM to be initiated.
62When performing a secure TRIM, the
63device guarantees that data stored on the trimmed blocks has been erased.
64This requires support from the device and is not supported by all SSDs.
65.It Fl r , -rate Ar rate
66Controls the rate at which the TRIM operation progresses.
67Without this
68option TRIM is executed as quickly as possible.
69The rate, expressed in bytes
70per second, is applied on a per-vdev basis and may be set differently for
71each leaf vdev.
72.It Fl c , -cancel
73Cancel trimming on the specified devices, or all eligible devices if none
74are specified.
75If one or more target devices are invalid or are not currently being
76trimmed, the command will fail and no cancellation will occur on any device.
77.It Fl s , -suspend
78Suspend 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 suspension will occur on any device.
82Trimming can then be resumed by running
83.Nm zpool Cm trim
84with no flags on the relevant target devices.
85.It Fl w , -wait
86Wait until the devices are done being trimmed before returning.
87.El
88.Sh PERIODIC TRIM
89On machines using systemd, trim timers can be enabled on a per-pool basis.
90.Nm weekly
91and
92.Nm monthly
93timer units are provided.
94.Bl -tag -width Ds
95.It Xo
96.Xc
97.Nm systemctl
98.Cm enable
99.Cm zfs-trim-\fIweekly\fB@\fIrpool\fB.timer
100.Cm --now
101.It Xo
102.Xc
103.Nm systemctl
104.Cm enable
105.Cm zfs-trim-\fImonthly\fB@\fIotherpool\fB.timer
106.Cm --now
107.El
108.
109.Sh SEE ALSO
110.Xr systemd.timer 5 ,
111.Xr zpoolprops 7 ,
112.Xr zpool-initialize 8 ,
113.Xr zpool-wait 8
114