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) 2025 iXsystems, Inc. 23.\" Copyright (c) 2025, Klara, Inc. 24.\" 25.Dd November 5, 2025 26.Dt ZFS-REWRITE 8 27.Os 28. 29.Sh NAME 30.Nm zfs-rewrite 31.Nd rewrite specified files without modification 32.Sh SYNOPSIS 33.Nm zfs 34.Cm rewrite 35.Oo Fl Prvx Ns Oc 36.Op Fl l Ar length 37.Op Fl o Ar offset 38.Ar file Ns | Ns Ar directory Ns … 39. 40.Sh DESCRIPTION 41Rewrite blocks of specified 42.Ar file 43as is without modification at a new location and possibly with new properties, 44as if they were atomically read and written back. 45.No See Sx NOTES . 46for more information about property changes that may be applied during rewrite. 47.Bl -tag -width "-r" 48.It Fl P 49Perform physical rewrite, preserving logical birth time of blocks. 50By default, rewrite updates logical birth times, making blocks appear 51as modified in snapshots and incremental send streams. 52Physical rewrite preserves logical birth times, avoiding unnecessary 53inclusion in incremental streams. 54Physical rewrite requires the 55.Sy physical_rewrite 56feature to be enabled on the pool. 57.It Fl l Ar length 58Rewrite at most this number of bytes. 59.It Fl o Ar offset 60Start at this offset in bytes. 61.It Fl r 62Recurse into directories. 63.It Fl v 64Print names of all successfully rewritten files. 65.It Fl x 66Don't cross file system mount points when recursing. 67.El 68.Sh NOTES 69Rewrite works by replacing an existing block with a new block of the same 70logical size. 71Changed dataset properties that operate on the data or metadata without 72changing the logical size will be applied. 73These include 74.Sy checksum , 75.Sy compression , 76.Sy dedup 77and 78.Sy copies . 79Changes to properties that affect the size of a logical block, like 80.Sy recordsize , 81will have no effect. 82.Pp 83Rewrite of cloned blocks and blocks that are part of any snapshots, 84same as some property changes may increase pool space usage. 85Holes that were never written or were previously zero-compressed are 86not rewritten and will remain holes even if compression is disabled. 87.Pp 88If a 89.Fl l 90or 91.Fl o 92value request a rewrite to regions past the end of the file, then those 93regions are silently ignored, and no error is reported. 94.Pp 95By default, rewritten blocks update their logical birth time, 96meaning they will be included in incremental 97.Nm zfs Cm send 98streams as modified data. 99When the 100.Fl P 101flag is used, rewritten blocks preserve their logical birth time, since 102there are no user data changes. 103. 104.Sh SEE ALSO 105.Xr zfsprops 7 , 106.Xr zpool-features 7 107