mirror_zfs/man/man8/zfs-rewrite.8
Rob Norris 7b121388fb man: describe zfs-rewrite method and properties
We've heard anecdotes that suggest some
confusion/surprise/disappointment that a changed recordsize is not
applied during rewrite. Until such time as we actually can do that, we
can at least explicitly mention it at something that doesn't work.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #17898
2025-11-12 13:06:10 -08:00

107 lines
3.2 KiB
Groff

.\" SPDX-License-Identifier: CDDL-1.0
.\"
.\" CDDL HEADER START
.\"
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or https://opensource.org/licenses/CDDL-1.0.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\" CDDL HEADER END
.\"
.\" Copyright (c) 2025 iXsystems, Inc.
.\" Copyright (c) 2025, Klara, Inc.
.\"
.Dd November 5, 2025
.Dt ZFS-REWRITE 8
.Os
.
.Sh NAME
.Nm zfs-rewrite
.Nd rewrite specified files without modification
.Sh SYNOPSIS
.Nm zfs
.Cm rewrite
.Oo Fl Prvx Ns Oc
.Op Fl l Ar length
.Op Fl o Ar offset
.Ar file Ns | Ns Ar directory Ns
.
.Sh DESCRIPTION
Rewrite blocks of specified
.Ar file
as is without modification at a new location and possibly with new properties,
as if they were atomically read and written back.
.No See Sx NOTES .
for more information about property changes that may be applied during rewrite.
.Bl -tag -width "-r"
.It Fl P
Perform physical rewrite, preserving logical birth time of blocks.
By default, rewrite updates logical birth times, making blocks appear
as modified in snapshots and incremental send streams.
Physical rewrite preserves logical birth times, avoiding unnecessary
inclusion in incremental streams.
Physical rewrite requires the
.Sy physical_rewrite
feature to be enabled on the pool.
.It Fl l Ar length
Rewrite at most this number of bytes.
.It Fl o Ar offset
Start at this offset in bytes.
.It Fl r
Recurse into directories.
.It Fl v
Print names of all successfully rewritten files.
.It Fl x
Don't cross file system mount points when recursing.
.El
.Sh NOTES
Rewrite works by replacing an existing block with a new block of the same
logical size.
Changed dataset properties that operate on the data or metadata without
changing the logical size will be applied.
These include
.Sy checksum ,
.Sy compression ,
.Sy dedup
and
.Sy copies .
Changes to properties that affect the size of a logical block, like
.Sy recordsize ,
will have no effect.
.Pp
Rewrite of cloned blocks and blocks that are part of any snapshots,
same as some property changes may increase pool space usage.
Holes that were never written or were previously zero-compressed are
not rewritten and will remain holes even if compression is disabled.
.Pp
If a
.Fl l
or
.Fl o
value request a rewrite to regions past the end of the file, then those
regions are silently ignored, and no error is reported.
.Pp
By default, rewritten blocks update their logical birth time,
meaning they will be included in incremental
.Nm zfs Cm send
streams as modified data.
When the
.Fl P
flag is used, rewritten blocks preserve their logical birth time, since
there are no user data changes.
.
.Sh SEE ALSO
.Xr zfsprops 7 ,
.Xr zpool-features 7