.\" SPDX-License-Identifier: CDDL-1.0 .\" .\" This file and its contents are supplied under the terms of the .\" Common Development and Distribution License ("CDDL"), version 1.0. .\" You may only use this file in accordance with the terms of version .\" 1.0 of the CDDL. .\" .\" A full copy of the text of the CDDL should have accompanied this .\" source. A copy of the CDDL is also available via the Internet at .\" https://opensource.org/license/CDDL-1.0. .\" .\" 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 CPSrvx 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 C Skip blocks that are shared via block cloning (BRT). Cloned blocks are referenced by multiple files or datasets. Rewriting these blocks would create separate copies and increase space usage. This flag prevents such expansion by skipping cloned blocks. .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 S Skip blocks that are shared with snapshots. Blocks created before the most recent snapshot are shared with that snapshot. Rewriting these blocks would create new copies, leaving the old copies for the snapshot and increasing space usage. This flag prevents such expansion by skipping snapshot-shared blocks. .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. Use the .Fl C and .Fl S flags to skip cloned and snapshot-shared blocks respectively to prevent this expansion. 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