xref: /freebsd/sys/contrib/openzfs/man/man8/zpool-trim.8 (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1*61145dc2SMartin Matuska.\" SPDX-License-Identifier: CDDL-1.0
2eda14cbcSMatt Macy.\"
3eda14cbcSMatt Macy.\" CDDL HEADER START
4eda14cbcSMatt Macy.\"
5eda14cbcSMatt Macy.\" The contents of this file are subject to the terms of the
6eda14cbcSMatt Macy.\" Common Development and Distribution License (the "License").
7eda14cbcSMatt Macy.\" You may not use this file except in compliance with the License.
8eda14cbcSMatt Macy.\"
9eda14cbcSMatt Macy.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10271171e0SMartin Matuska.\" or https://opensource.org/licenses/CDDL-1.0.
11eda14cbcSMatt Macy.\" See the License for the specific language governing permissions
12eda14cbcSMatt Macy.\" and limitations under the License.
13eda14cbcSMatt Macy.\"
14eda14cbcSMatt Macy.\" When distributing Covered Code, include this CDDL HEADER in each
15eda14cbcSMatt Macy.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16eda14cbcSMatt Macy.\" If applicable, add the following below this CDDL HEADER, with the
17eda14cbcSMatt Macy.\" fields enclosed by brackets "[]" replaced with your own identifying
18eda14cbcSMatt Macy.\" information: Portions Copyright [yyyy] [name of copyright owner]
19eda14cbcSMatt Macy.\"
20eda14cbcSMatt Macy.\" CDDL HEADER END
21eda14cbcSMatt Macy.\"
22eda14cbcSMatt Macy.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
23eda14cbcSMatt Macy.\" Copyright (c) 2012, 2018 by Delphix. All rights reserved.
24eda14cbcSMatt Macy.\" Copyright (c) 2012 Cyril Plisko. All Rights Reserved.
25eda14cbcSMatt Macy.\" Copyright (c) 2017 Datto Inc.
26eda14cbcSMatt Macy.\" Copyright (c) 2018 George Melikov. All Rights Reserved.
27eda14cbcSMatt Macy.\" Copyright 2017 Nexenta Systems, Inc.
28eda14cbcSMatt Macy.\" Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
29eda14cbcSMatt Macy.\"
3016038816SMartin Matuska.Dd May 27, 2021
31eda14cbcSMatt Macy.Dt ZPOOL-TRIM 8
32eda14cbcSMatt Macy.Os
3316038816SMartin Matuska.
34eda14cbcSMatt Macy.Sh NAME
357877fdebSMatt Macy.Nm zpool-trim
3616038816SMartin Matuska.Nd initiate TRIM of free space in ZFS storage pool
37eda14cbcSMatt Macy.Sh SYNOPSIS
387877fdebSMatt Macy.Nm zpool
39eda14cbcSMatt Macy.Cm trim
40eda14cbcSMatt Macy.Op Fl dw
41eda14cbcSMatt Macy.Op Fl r Ar rate
4216038816SMartin Matuska.Op Fl c Ns | Ns Fl s
43eda14cbcSMatt Macy.Ar pool
4416038816SMartin Matuska.Oo Ar device Ns Oc Ns …
4516038816SMartin Matuska.
46eda14cbcSMatt Macy.Sh DESCRIPTION
47eda14cbcSMatt MacyInitiates an immediate on-demand TRIM operation for all of the free space in
4816038816SMartin Matuskaa pool.
4916038816SMartin MatuskaThis operation informs the underlying storage devices of all blocks
50eda14cbcSMatt Macyin the pool which are no longer allocated and allows thinly provisioned
51eda14cbcSMatt Macydevices to reclaim the space.
52eda14cbcSMatt Macy.Pp
53eda14cbcSMatt MacyA manual on-demand TRIM operation can be initiated irrespective of the
54eda14cbcSMatt Macy.Sy autotrim
5516038816SMartin Matuskapool property setting.
5616038816SMartin MatuskaSee the documentation for the
57eda14cbcSMatt Macy.Sy autotrim
58eda14cbcSMatt Macyproperty above for the types of vdev devices which can be trimmed.
59eda14cbcSMatt Macy.Bl -tag -width Ds
6016038816SMartin Matuska.It Fl d , -secure
6116038816SMartin MatuskaCauses a secure TRIM to be initiated.
6216038816SMartin MatuskaWhen performing a secure TRIM, the
63eda14cbcSMatt Macydevice guarantees that data stored on the trimmed blocks has been erased.
64eda14cbcSMatt MacyThis requires support from the device and is not supported by all SSDs.
6516038816SMartin Matuska.It Fl r , -rate Ar rate
6616038816SMartin MatuskaControls the rate at which the TRIM operation progresses.
6716038816SMartin MatuskaWithout this
6816038816SMartin Matuskaoption TRIM is executed as quickly as possible.
6916038816SMartin MatuskaThe rate, expressed in bytes
70eda14cbcSMatt Macyper second, is applied on a per-vdev basis and may be set differently for
71eda14cbcSMatt Macyeach leaf vdev.
72eda14cbcSMatt Macy.It Fl c , -cancel
73eda14cbcSMatt MacyCancel trimming on the specified devices, or all eligible devices if none
74eda14cbcSMatt Macyare specified.
75eda14cbcSMatt MacyIf one or more target devices are invalid or are not currently being
76eda14cbcSMatt Macytrimmed, the command will fail and no cancellation will occur on any device.
7716038816SMartin Matuska.It Fl s , -suspend
78eda14cbcSMatt MacySuspend trimming on the specified devices, or all eligible devices if none
79eda14cbcSMatt Macyare specified.
80eda14cbcSMatt MacyIf one or more target devices are invalid or are not currently being
81eda14cbcSMatt Macytrimmed, the command will fail and no suspension will occur on any device.
82eda14cbcSMatt MacyTrimming can then be resumed by running
83eda14cbcSMatt Macy.Nm zpool Cm trim
84eda14cbcSMatt Macywith no flags on the relevant target devices.
8516038816SMartin Matuska.It Fl w , -wait
86eda14cbcSMatt MacyWait until the devices are done being trimmed before returning.
87eda14cbcSMatt Macy.El
881f1e2261SMartin Matuska.Sh PERIODIC TRIM
891f1e2261SMartin MatuskaOn machines using systemd, trim timers can be enabled on a per-pool basis.
901f1e2261SMartin Matuska.Nm weekly
911f1e2261SMartin Matuskaand
921f1e2261SMartin Matuska.Nm monthly
931f1e2261SMartin Matuskatimer units are provided.
941f1e2261SMartin Matuska.Bl -tag -width Ds
951f1e2261SMartin Matuska.It Xo
961f1e2261SMartin Matuska.Xc
971f1e2261SMartin Matuska.Nm systemctl
981f1e2261SMartin Matuska.Cm enable
991f1e2261SMartin Matuska.Cm zfs-trim-\fIweekly\fB@\fIrpool\fB.timer
1001f1e2261SMartin Matuska.Cm --now
1011f1e2261SMartin Matuska.It Xo
1021f1e2261SMartin Matuska.Xc
1031f1e2261SMartin Matuska.Nm systemctl
1041f1e2261SMartin Matuska.Cm enable
1051f1e2261SMartin Matuska.Cm zfs-trim-\fImonthly\fB@\fIotherpool\fB.timer
1061f1e2261SMartin Matuska.Cm --now
1071f1e2261SMartin Matuska.El
10816038816SMartin Matuska.
109eda14cbcSMatt Macy.Sh SEE ALSO
1101f1e2261SMartin Matuska.Xr systemd.timer 5 ,
1113ff01b23SMartin Matuska.Xr zpoolprops 7 ,
112eda14cbcSMatt Macy.Xr zpool-initialize 8 ,
1133ff01b23SMartin Matuska.Xr zpool-wait 8
114