xref: /src/sys/contrib/openzfs/man/man8/zfs-rewrite.8 (revision 8a62a2a5659d1839d8799b4274c04469d7f17c78)
149fbdd45SAlexander Motin.\" SPDX-License-Identifier: CDDL-1.0
249fbdd45SAlexander Motin.\"
349fbdd45SAlexander Motin.\" CDDL HEADER START
449fbdd45SAlexander Motin.\"
549fbdd45SAlexander Motin.\" The contents of this file are subject to the terms of the
649fbdd45SAlexander Motin.\" Common Development and Distribution License (the "License").
749fbdd45SAlexander Motin.\" You may not use this file except in compliance with the License.
849fbdd45SAlexander Motin.\"
949fbdd45SAlexander Motin.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1049fbdd45SAlexander Motin.\" or https://opensource.org/licenses/CDDL-1.0.
1149fbdd45SAlexander Motin.\" See the License for the specific language governing permissions
1249fbdd45SAlexander Motin.\" and limitations under the License.
1349fbdd45SAlexander Motin.\"
1449fbdd45SAlexander Motin.\" When distributing Covered Code, include this CDDL HEADER in each
1549fbdd45SAlexander Motin.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1649fbdd45SAlexander Motin.\" If applicable, add the following below this CDDL HEADER, with the
1749fbdd45SAlexander Motin.\" fields enclosed by brackets "[]" replaced with your own identifying
1849fbdd45SAlexander Motin.\" information: Portions Copyright [yyyy] [name of copyright owner]
1949fbdd45SAlexander Motin.\"
2049fbdd45SAlexander Motin.\" CDDL HEADER END
2149fbdd45SAlexander Motin.\"
2249fbdd45SAlexander Motin.\" Copyright (c) 2025 iXsystems, Inc.
23336c9537SRob Norris.\" Copyright (c) 2025, Klara, Inc.
2449fbdd45SAlexander Motin.\"
25336c9537SRob Norris.Dd November 5, 2025
2649fbdd45SAlexander Motin.Dt ZFS-REWRITE 8
2749fbdd45SAlexander Motin.Os
2849fbdd45SAlexander Motin.
2949fbdd45SAlexander Motin.Sh NAME
3049fbdd45SAlexander Motin.Nm zfs-rewrite
3149fbdd45SAlexander Motin.Nd rewrite specified files without modification
3249fbdd45SAlexander Motin.Sh SYNOPSIS
3349fbdd45SAlexander Motin.Nm zfs
3449fbdd45SAlexander Motin.Cm rewrite
352646bd55SAlexander Motin.Oo Fl CPSrvx Ns Oc
3649fbdd45SAlexander Motin.Op Fl l Ar length
3749fbdd45SAlexander Motin.Op Fl o Ar offset
3849fbdd45SAlexander Motin.Ar file Ns | Ns Ar directory Ns …
3949fbdd45SAlexander Motin.
4049fbdd45SAlexander Motin.Sh DESCRIPTION
4149fbdd45SAlexander MotinRewrite blocks of specified
4249fbdd45SAlexander Motin.Ar file
43336c9537SRob Norrisas is without modification at a new location and possibly with new properties,
4449fbdd45SAlexander Motinas if they were atomically read and written back.
45336c9537SRob Norris.No See Sx NOTES .
46336c9537SRob Norrisfor more information about property changes that may be applied during rewrite.
4749fbdd45SAlexander Motin.Bl -tag -width "-r"
482646bd55SAlexander Motin.It Fl C
492646bd55SAlexander MotinSkip blocks that are shared via block cloning (BRT).
502646bd55SAlexander MotinCloned blocks are referenced by multiple files or datasets.
512646bd55SAlexander MotinRewriting these blocks would create separate copies and increase space usage.
522646bd55SAlexander MotinThis flag prevents such expansion by skipping cloned blocks.
5360f714e6SAlexander Motin.It Fl P
5460f714e6SAlexander MotinPerform physical rewrite, preserving logical birth time of blocks.
5560f714e6SAlexander MotinBy default, rewrite updates logical birth times, making blocks appear
5660f714e6SAlexander Motinas modified in snapshots and incremental send streams.
5760f714e6SAlexander MotinPhysical rewrite preserves logical birth times, avoiding unnecessary
5860f714e6SAlexander Motininclusion in incremental streams.
5960f714e6SAlexander MotinPhysical rewrite requires the
6060f714e6SAlexander Motin.Sy physical_rewrite
6160f714e6SAlexander Motinfeature to be enabled on the pool.
622646bd55SAlexander Motin.It Fl S
632646bd55SAlexander MotinSkip blocks that are shared with snapshots.
642646bd55SAlexander MotinBlocks created before the most recent snapshot are shared with that snapshot.
652646bd55SAlexander MotinRewriting these blocks would create new copies, leaving the old copies for
662646bd55SAlexander Motinthe snapshot and increasing space usage.
672646bd55SAlexander MotinThis flag prevents such expansion by skipping snapshot-shared blocks.
6849fbdd45SAlexander Motin.It Fl l Ar length
6949fbdd45SAlexander MotinRewrite at most this number of bytes.
7049fbdd45SAlexander Motin.It Fl o Ar offset
7149fbdd45SAlexander MotinStart at this offset in bytes.
7249fbdd45SAlexander Motin.It Fl r
7349fbdd45SAlexander MotinRecurse into directories.
7449fbdd45SAlexander Motin.It Fl v
7549fbdd45SAlexander MotinPrint names of all successfully rewritten files.
7649fbdd45SAlexander Motin.It Fl x
7749fbdd45SAlexander MotinDon't cross file system mount points when recursing.
7849fbdd45SAlexander Motin.El
7949fbdd45SAlexander Motin.Sh NOTES
80336c9537SRob NorrisRewrite works by replacing an existing block with a new block of the same
81336c9537SRob Norrislogical size.
82336c9537SRob NorrisChanged dataset properties that operate on the data or metadata without
83336c9537SRob Norrischanging the logical size will be applied.
84336c9537SRob NorrisThese include
85336c9537SRob Norris.Sy checksum ,
86336c9537SRob Norris.Sy compression ,
87336c9537SRob Norris.Sy dedup
88336c9537SRob Norrisand
89336c9537SRob Norris.Sy copies .
90336c9537SRob NorrisChanges to properties that affect the size of a logical block, like
91336c9537SRob Norris.Sy recordsize ,
92336c9537SRob Norriswill have no effect.
93336c9537SRob Norris.Pp
9449fbdd45SAlexander MotinRewrite of cloned blocks and blocks that are part of any snapshots,
9549fbdd45SAlexander Motinsame as some property changes may increase pool space usage.
962646bd55SAlexander MotinUse the
972646bd55SAlexander Motin.Fl C
982646bd55SAlexander Motinand
992646bd55SAlexander Motin.Fl S
1002646bd55SAlexander Motinflags to skip cloned and snapshot-shared blocks respectively to prevent
1012646bd55SAlexander Motinthis expansion.
10249fbdd45SAlexander MotinHoles that were never written or were previously zero-compressed are
10349fbdd45SAlexander Motinnot rewritten and will remain holes even if compression is disabled.
10449fbdd45SAlexander Motin.Pp
10549fbdd45SAlexander MotinIf a
10649fbdd45SAlexander Motin.Fl l
10749fbdd45SAlexander Motinor
10849fbdd45SAlexander Motin.Fl o
10949fbdd45SAlexander Motinvalue request a rewrite to regions past the end of the file, then those
11049fbdd45SAlexander Motinregions are silently ignored, and no error is reported.
11160f714e6SAlexander Motin.Pp
11260f714e6SAlexander MotinBy default, rewritten blocks update their logical birth time,
11360f714e6SAlexander Motinmeaning they will be included in incremental
11460f714e6SAlexander Motin.Nm zfs Cm send
11560f714e6SAlexander Motinstreams as modified data.
11660f714e6SAlexander MotinWhen the
11760f714e6SAlexander Motin.Fl P
11860f714e6SAlexander Motinflag is used, rewritten blocks preserve their logical birth time, since
11960f714e6SAlexander Motinthere are no user data changes.
12049fbdd45SAlexander Motin.
12149fbdd45SAlexander Motin.Sh SEE ALSO
12260f714e6SAlexander Motin.Xr zfsprops 7 ,
12360f714e6SAlexander Motin.Xr zpool-features 7
124