Skip to content

Add option to recompress/rechecksum existing data on property change #18176

@unixdruid

Description

@unixdruid

Describe the feature you would like to see added to OpenZFS

Add a command or flag to rewrite existing data in-place when compression or checksum properties are changed, allowing datasets to be fully migrated to new algorithms without manual workarounds.

Proposed syntax:

zfs rewrite pool/dataset

Or as a flag:

zfs set -o rewrite checksum=sha256 pool/dataset

This would traverse the dataset and rewrite blocks with the new compression/checksum algorithms while preserving all metadata, timestamps, permissions, and attributes.

How will this feature improve OpenZFS?

Problem: Changing checksum from fletcher4 to sha256 (for example NOOPwrite) or changing compression algorithms only affects new writes. Existing data remains in the old format indefinitely unless manually rewritten.

Benefits:

  • Enable NOOPwrite on existing datasets (fletcher4→sha256 migration)
  • Migrate to better compression algorithms (lz4→zstd) without space penalties
  • Improve data integrity by upgrading to stronger checksums
  • Single command instead of complex workarounds

Similar features:

  • btrfs: btrfs balance for compression migration
  • bcachefs: automatic recompression on algorithm change

Additional context

Real-world scenario: I have a dataset with fletcher4 checksums and want to enable NOOPwrite (requires sha256). With ~168GB of data, current options are:

  1. Wait indefinitely for natural rewrites
  2. Double my storage for send/recv
  3. Write custom scripts with find | xargs | dd

A zfs rewrite command would make this trivial and safe.

Implementation considerations:

  • Should be interruptible/resumable
  • Progress reporting (similar to zpool scrub)
  • Option to rewrite specific properties only (checksum vs compression vs both)
  • Preserve refcounts for snapshots/clones
  • Could be background operation like scrub/resilver

Thanks,
UD.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: FeatureFeature request or new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions