zfs-rewrite.8

ZFS-REWRITE(8) System Manager's Manual ZFS-REWRITE(8)

zfs-rewrite — rewrite specified files without modification

zfs rewrite [-CPSWrvx] [-l length] [-o offset] file|directory…

Rewrite blocks of specified file as is without modification at a new location and possibly with new properties, as if they were atomically read and written back. See NOTES. for more information about property changes that may be applied during rewrite.

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.
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 feature to be enabled on the pool.
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.
Skip blocks whose rewrite would not change their allocated size. After a RAID-Z expansion, only the blocks written before it completed that the new width stores in less space are rewritten, so an interrupted rewrite can be run again without rewriting the same blocks twice. Blocks smaller than the old width keep their size and stay in place, which can leave the space freed around them fragmented. A size change that a property change would cause, as with compression, is not taken into account. On vdevs other than RAID-Z, only gang blocks and blocks on removed devices are rewritten.
length
Rewrite at most this number of bytes.
offset
Start at this offset in bytes.
Recurse into directories.
Print names of all successfully rewritten files.
Don't cross file system mount points when recursing.

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 , compression, and . Changes to properties that affect the size of a logical block, like , will have no effect.

Rewrite of cloned blocks and blocks that are part of any snapshots, same as some property changes may increase pool space usage. Use the -C and -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.

On a RAID-Z vdev, rewritten blocks use the width of the vdev once its expansion has completed, see zpool-attach(8). Blocks rewritten while the expansion is in progress keep their old width. Blocks that are already deduplicated stay where they are, and keep their width.

If a -l or -o value request a rewrite to regions past the end of the file, then those regions are silently ignored, and no error is reported.

By default, rewritten blocks update their logical birth time, meaning they will be included in incremental zfs send streams as modified data. When the -P flag is used, rewritten blocks preserve their logical birth time, since there are no user data changes.

zfsprops(7), zpool-features(7), zpool-attach(8)

October 13, 2026 Debian