zstream8
Manipulate zfs send streams
Usage
zstream decompress
[-v]
[object,offset
[,compress_type]
…]
[file]
zstream drop_records
[-v]
[object,offset…]
[file]
zstream dump
[-Cvd]
[file]
zstream {raw
[-v]
[-b
max_buffers]
[-g
fromguid]
image | device
[file]}
zstream recompress
[-t
num_threads]
compress_type
[file]
zstream redup
[-v]
file
zstream token
resume_token
Overview
zstream performs various operations on send streams created by the zfs send command. Aside from the token subcommand, which takes a resume token rather than a stream, every subcommand reads a send stream either from the file named as its last argument or, when no file is given, from standard input. The redup subcommand requires a file; it rereads earlier parts of the stream to resolve deduplicated records, so it cannot accept input from a pipe.
-
zstreamdecompress[-v] [object,offset[,compress_type]…] [file] Decompresses specified records within a send stream. This subcommand can be used to recover data when the compression type recorded in the ZFS metadata is incorrect. Specify the object number and byte offset of each record to be decompressed. Optionally, specify the (true) compress_type. The compress_type can be any value accepted by thecompressionproperty excepton, such asoff,gzip,lz4,lzjb,zstd, orzle. A compression level (e.g.,gzip-3orzstd-5) is accepted but ignored; only the algorithm matters when decompressing. If no compress_type is given, the compression type recorded in the record's own metadata is used.Every record for that object beginning at that offset is decompressed, if possible. It may not be possible, because a record can be corrupt in some of the stream's snapshots but not in others.
Specifying a compression type of
offchanges the stream's metadata accordingly, without attempting decompression. This can be useful if the record is already uncompressed but the metadata insists otherwise.The repaired stream is written to standard output.
-
-v -
Verbose. Prints a summary of decompressed records.
-
-
zstreamdrop_records[-v] [object,offset…] [file] Removes selected records, specified by object number and byte offset, from a send stream read from the specified file or from standard input. Currently, only WRITE and WRITE_EMBEDDED records can be dropped. The repaired stream is written to standard output.-
-v -
Verbose. Prints a summary of dropped records.
-
-
zstreamdump[-Cvd] [file] Prints information about the specified send stream, including headers and record counts. The stream is read from either the specified file or standard input.-
-C -
Suppresses the validation of checksums.
-
-v -
Verbose. Prints metadata for each record. This option can be repeated to also print record checksums.
-
-d -
Dumps the data contained in each record as well as checksums. Implies verbose.
The
zstreamdumpalias is provided for compatibility and is equivalent to runningzstreamdump.
-
-
zstreamraw[-v] [-bmax_buffers] [-gfromguid] image|device [file] Applies a zvol send stream, read from the specified file or from standard input, to a raw image or block device. By default, at most 32 SPA_MAXBLOCKSIZE buffers can be written at a time. With max_buffers set to some value between 1 and IOV_MAX, contiguous write records are combined into one write operation using up to this many buffers, at the cost of additional memory use. When a fromguid is provided, the initial fromguid of the stream is checked to ensure that it matches the given value. The final toguid of the stream is printed to standard output on completion. With the-voption, details of the records in the stream are printed in similar fashion tozstreamdump. -
zstreamrecompress[-tnum_threads] compress_type [file] Recompresses a send stream, read from the specified file or from standard input, using the specified compress_type, and writes the modified stream to standard output. All WRITE records in the send stream are compressed unless compression fails to reduce their size compared to leaving them uncompressed. The compress_type can be any value accepted by thecompressionproperty excepton, including those that name a compression level, such asgzip-3orzstd-5. A compress_type ofoffdecompresses every record and leaves the stream uncompressed. Note that encrypted send streams cannot be recompressed.-
-t num_threads -
Specifies the number of compression worker threads. By default,
zstreamrecompresscreates a thread for every CPU core. It is generally unproductive to raise num_threads above this default. On some architectures, contention for resources such as memory caches can reduce efficiency when many threads are active. On those systems, it may be helpful to run with fewer threads, particularly when automating operations on shared servers. -
-l level -
This option is deprecated. It formerly specified a numeric compression level for
zstd. Use a standard compression specifier such aszstd-5instead.
-
-
zstreamredup[-v] file It was formerly possible to create deduplicated send streams with thezfssend-Doption. However, support for stream-level deduplication has been deprecated and removed from bothzfssendandzfsreceive.zstreamredupreads a deduplicated stream from the specified file and outputs an equivalent, non-deduplicated send stream on standard output. Therefore, a deduplicated stream can be received by running:# zstream redup file | zfs receive …
A real file is required here because resolving deduplicated records involves rereading earlier parts of the stream.
-
-v -
Verbose. Prints a summary of reduplicated records.
-
-
zstreamtokenresume_token Dumps ZFS resume token information.
Examples
Recovering from OpenZFS bug #12762
First, determine which records are corrupt. That cannot be done automatically; it requires information beyond ZFS's metadata. If object 128 is corrupted at offset 0 and is compressed using lz4, then run this command:
# zfs send -c … | zstream decompress 128,0,lz4 | zfs recv …
Recovering from OpenZFS bug #18239
The bogus records typically have an absurdly large offset that can be discovered by running zdb -ddddd dataset object or zstream dump -v. To recover, send the dataset and use zstream to drop the bogus record, then receive it into a new dataset.
# zfs send … | zstream drop_records 3545761,18446744073709486080 | zfs recv …
Migrating from a zvol to a physical disk
Given an adequately sized physical disk /dev/sdd and a zvol tank/vol with snapshots @1, @2, and @3:
# zfs send -Lec tank/vol@1 | zstream raw /dev/sdd 16731506615198184313 # zfs send -Lec -I @1 tank/vol@3 | zstream raw -g 16731506615198184313 /dev/sdd 10690368765373298656
Releases
15 releases since FreeBSD 13.0-RELEASE; the text changed 4 times.
-l since FreeBSD 14.0-RELEASE;
-t since FreeBSD 16.0-CURRENT (2026-10-27).