xref: /freebsd/sys/contrib/openzfs/man/man8/zdb.8 (revision 87b759f0fa1f7554d50ce640c40138512bbded44)
1.\"
2.\" This file and its contents are supplied under the terms of the
3.\" Common Development and Distribution License ("CDDL"), version 1.0.
4.\" You may only use this file in accordance with the terms of version
5.\" 1.0 of the CDDL.
6.\"
7.\" A full copy of the text of the CDDL should have accompanied this
8.\" source.  A copy of the CDDL is also available via the Internet at
9.\" http://www.illumos.org/license/CDDL.
10.\"
11.\" Copyright 2012, Richard Lowe.
12.\" Copyright (c) 2012, 2019 by Delphix. All rights reserved.
13.\" Copyright 2017 Nexenta Systems, Inc.
14.\" Copyright (c) 2017 Lawrence Livermore National Security, LLC.
15.\" Copyright (c) 2017 Intel Corporation.
16.\"
17.Dd November 18, 2023
18.Dt ZDB 8
19.Os
20.
21.Sh NAME
22.Nm zdb
23.Nd display ZFS storage pool debugging and consistency information
24.Sh SYNOPSIS
25.Nm
26.Op Fl AbcdDFGhikLMNPsTvXYy
27.Op Fl e Oo Fl V Oc Oo Fl p Ar path Oc Ns …
28.Op Fl I Ar inflight-I/O-ops
29.Oo Fl o Ar var Ns = Ns Ar value Oc Ns …
30.Op Fl t Ar txg
31.Op Fl U Ar cache
32.Op Fl x Ar dumpdir
33.Op Fl K Ar key
34.Op Ar poolname Ns Op / Ns Ar dataset Ns | Ns Ar objset-ID
35.Op Ar object Ns | Ns Ar range Ns …
36.Nm
37.Op Fl AdiPv
38.Op Fl e Oo Fl V Oc Oo Fl p Ar path Oc Ns …
39.Op Fl U Ar cache
40.Op Fl K Ar key
41.Ar poolname Ns Op Ar / Ns Ar dataset Ns | Ns Ar objset-ID
42.Op Ar object Ns | Ns Ar range Ns …
43.Nm
44.Fl B
45.Op Fl e Oo Fl V Oc Oo Fl p Ar path Oc Ns …
46.Op Fl U Ar cache
47.Op Fl K Ar key
48.Ar poolname Ns Ar / Ns Ar objset-ID
49.Op Ar backup-flags
50.Nm
51.Fl C
52.Op Fl A
53.Op Fl U Ar cache
54.Op Ar poolname
55.Nm
56.Fl E
57.Op Fl A
58.Ar word0 : Ns Ar word1 Ns :…: Ns Ar word15
59.Nm
60.Fl l
61.Op Fl Aqu
62.Ar device
63.Nm
64.Fl m
65.Op Fl AFLPXY
66.Op Fl e Oo Fl V Oc Oo Fl p Ar path Oc Ns …
67.Op Fl t Ar txg
68.Op Fl U Ar cache
69.Ar poolname Op Ar vdev Oo Ar metaslab Oc Ns …
70.Nm
71.Fl O
72.Op Fl K Ar key
73.Ar dataset path
74.Nm
75.Fl r
76.Op Fl K Ar key
77.Ar dataset path destination
78.Nm
79.Fl R
80.Op Fl A
81.Op Fl e Oo Fl V Oc Oo Fl p Ar path Oc Ns …
82.Op Fl U Ar cache
83.Ar poolname vdev : Ns Ar offset : Ns Oo Ar lsize Ns / Oc Ns Ar psize Ns Op : Ns Ar flags
84.Nm
85.Fl S
86.Op Fl AP
87.Op Fl e Oo Fl V Oc Oo Fl p Ar path Oc Ns …
88.Op Fl U Ar cache
89.Ar poolname
90.
91.Sh DESCRIPTION
92The
93.Nm
94utility displays information about a ZFS pool useful for debugging and performs
95some amount of consistency checking.
96It is a not a general purpose tool and options
97.Pq and facilities
98may change.
99It is not a
100.Xr fsck 8
101utility.
102.Pp
103The output of this command in general reflects the on-disk structure of a ZFS
104pool, and is inherently unstable.
105The precise output of most invocations is not documented, a knowledge of ZFS
106internals is assumed.
107.Pp
108If the
109.Ar dataset
110argument does not contain any
111.Qq Sy /
112or
113.Qq Sy @
114characters, it is interpreted as a pool name.
115The root dataset can be specified as
116.Qq Ar pool Ns / .
117.Pp
118.Nm
119is an
120.Qq offline
121tool; it accesses the block devices underneath the pools directly from
122userspace and does not care if the pool is imported or datasets are mounted
123(or even if the system understands ZFS at all).
124When operating on an imported and active pool it is possible, though unlikely,
125that zdb may interpret inconsistent pool data and behave erratically.
126.
127.Sh OPTIONS
128Display options:
129.Bl -tag -width Ds
130.It Fl b , -block-stats
131Display statistics regarding the number, size
132.Pq logical, physical and allocated
133and deduplication of blocks.
134.It Fl B , -backup
135Generate a backup stream, similar to
136.Nm zfs Cm send ,
137but for the numeric objset ID, and without opening the dataset.
138This can be useful in recovery scenarios if dataset metadata has become
139corrupted but the dataset itself is readable.
140The optional
141.Ar flags
142argument is a string of one or more of the letters
143.Sy e ,
144.Sy L ,
145.Sy c ,
146and
147.Sy w ,
148which correspond to the same flags in
149.Xr zfs-send 8 .
150.It Fl c , -checksum
151Verify the checksum of all metadata blocks while printing block statistics
152.Po see
153.Fl b
154.Pc .
155.Pp
156If specified multiple times, verify the checksums of all blocks.
157.It Fl C , -config
158Display information about the configuration.
159If specified with no other options, instead display information about the cache
160file
161.Pq Pa /etc/zfs/zpool.cache .
162To specify the cache file to display, see
163.Fl U .
164.Pp
165If specified multiple times, and a pool name is also specified display both the
166cached configuration and the on-disk configuration.
167If specified multiple times with
168.Fl e
169also display the configuration that would be used were the pool to be imported.
170.It Fl d , -datasets
171Display information about datasets.
172Specified once, displays basic dataset information: ID, create transaction,
173size, and object count.
174See
175.Fl N
176for determining if
177.Ar poolname Ns Op / Ns Ar dataset Ns | Ns Ar objset-ID
178is to use the specified
179.Ar dataset Ns | Ns Ar objset-ID
180as a string (dataset name) or a number (objset ID) when
181datasets have numeric names.
182.Pp
183If specified multiple times provides greater and greater verbosity.
184.Pp
185If object IDs or object ID ranges are specified, display information about
186those specific objects or ranges only.
187.Pp
188An object ID range is specified in terms of a colon-separated tuple of
189the form
190.Ao start Ac : Ns Ao end Ac Ns Op : Ns Ao flags Ac .
191The fields
192.Ar start
193and
194.Ar end
195are integer object identifiers that denote the upper and lower bounds
196of the range.
197An
198.Ar end
199value of -1 specifies a range with no upper bound.
200The
201.Ar flags
202field optionally specifies a set of flags, described below, that control
203which object types are dumped.
204By default, all object types are dumped.
205A minus sign
206.Pq -
207negates the effect of the flag that follows it and has no effect unless
208preceded by the
209.Ar A
210flag.
211For example, the range 0:-1:A-d will dump all object types except for
212directories.
213.Pp
214.Bl -tag -compact -width Ds
215.It Sy A
216Dump all objects (this is the default)
217.It Sy d
218Dump ZFS directory objects
219.It Sy f
220Dump ZFS plain file objects
221.It Sy m
222Dump SPA space map objects
223.It Sy z
224Dump ZAP objects
225.It Sy -
226Negate the effect of next flag
227.El
228.It Fl D , -dedup-stats
229Display deduplication statistics, including the deduplication ratio
230.Pq Sy dedup ,
231compression ratio
232.Pq Sy compress ,
233inflation due to the zfs copies property
234.Pq Sy copies ,
235and an overall effective ratio
236.Pq Sy dedup No \(mu Sy compress No / Sy copies .
237.It Fl DD
238Display a histogram of deduplication statistics, showing the allocated
239.Pq physically present on disk
240and referenced
241.Pq logically referenced in the pool
242block counts and sizes by reference count.
243.It Fl DDD
244Display the statistics independently for each deduplication table.
245.It Fl DDDD
246Dump the contents of the deduplication tables describing duplicate blocks.
247.It Fl DDDDD
248Also dump the contents of the deduplication tables describing unique blocks.
249.It Fl E , -embedded-block-pointer Ns = Ns Ar word0 : Ns Ar word1 Ns :…: Ns Ar word15
250Decode and display block from an embedded block pointer specified by the
251.Ar word
252arguments.
253.It Fl h , -history
254Display pool history similar to
255.Nm zpool Cm history ,
256but include internal changes, transaction, and dataset information.
257.It Fl i , -intent-logs
258Display information about intent log
259.Pq ZIL
260entries relating to each dataset.
261If specified multiple times, display counts of each intent log transaction type.
262.It Fl k , -checkpointed-state
263Examine the checkpointed state of the pool.
264Note, the on disk format of the pool is not reverted to the checkpointed state.
265.It Fl l , -label Ns = Ns Ar device
266Read the vdev labels and L2ARC header from the specified device.
267.Nm Fl l
268will return 0 if valid label was found, 1 if error occurred, and 2 if no valid
269labels were found.
270The presence of L2ARC header is indicated by a specific
271sequence (L2ARC_DEV_HDR_MAGIC).
272If there is an accounting error in the size or the number of L2ARC log blocks
273.Nm Fl l
274will return 1.
275Each unique configuration is displayed only once.
276.It Fl ll Ar device
277In addition display label space usage stats.
278If a valid L2ARC header was found
279also display the properties of log blocks used for restoring L2ARC contents
280(persistent L2ARC).
281.It Fl lll Ar device
282Display every configuration, unique or not.
283If a valid L2ARC header was found
284also display the properties of log entries in log blocks used for restoring
285L2ARC contents (persistent L2ARC).
286.Pp
287If the
288.Fl q
289option is also specified, don't print the labels or the L2ARC header.
290.Pp
291If the
292.Fl u
293option is also specified, also display the uberblocks on this device.
294Specify multiple times to increase verbosity.
295.It Fl L , -disable-leak-tracking
296Disable leak detection and the loading of space maps.
297By default,
298.Nm
299verifies that all non-free blocks are referenced, which can be very expensive.
300.It Fl m , -metaslabs
301Display the offset, spacemap, free space of each metaslab, all the log
302spacemaps and their obsolete entry statistics.
303.It Fl mm
304Also display information about the on-disk free space histogram associated with
305each metaslab.
306.It Fl mmm
307Display the maximum contiguous free space, the in-core free space histogram, and
308the percentage of free space in each space map.
309.It Fl mmmm
310Display every spacemap record.
311.It Fl M , -metaslab-groups
312Display all "normal" vdev metaslab group information - per-vdev metaslab count,
313fragmentation,
314and free space histogram, as well as overall pool fragmentation and histogram.
315.It Fl MM
316"Special" vdevs are added to -M's normal output.
317Also display information about the maximum contiguous free space and the
318percentage of free space in each space map.
319.It Fl MMM
320Display every spacemap record.
321.It Fl N
322Same as
323.Fl d
324but force zdb to interpret the
325.Op Ar dataset Ns | Ns Ar objset-ID
326in
327.Op Ar poolname Ns Op / Ns Ar dataset Ns | Ns Ar objset-ID
328as a numeric objset ID.
329.It Fl O , -object-lookups Ns = Ns Ar dataset path
330Look up the specified
331.Ar path
332inside of the
333.Ar dataset
334and display its metadata and indirect blocks.
335Specified
336.Ar path
337must be relative to the root of
338.Ar dataset .
339This option can be combined with
340.Fl v
341for increasing verbosity.
342.It Fl r , -copy-object Ns = Ns Ar dataset path destination
343Copy the specified
344.Ar path
345inside of the
346.Ar dataset
347to the specified destination.
348Specified
349.Ar path
350must be relative to the root of
351.Ar dataset .
352This option can be combined with
353.Fl v
354for increasing verbosity.
355.It Xo
356.Fl R , -read-block Ns = Ns Ar poolname vdev : Ns Ar offset : Ns Oo Ar lsize Ns / Oc Ns Ar psize Ns Op : Ns Ar flags
357.Xc
358Read and display a block from the specified device.
359By default the block is displayed as a hex dump, but see the description of the
360.Sy r
361flag, below.
362.Pp
363The block is specified in terms of a colon-separated tuple
364.Ar vdev
365.Pq an integer vdev identifier
366.Ar offset
367.Pq the offset within the vdev
368.Ar size
369.Pq the physical size, or logical size / physical size
370of the block to read and, optionally,
371.Ar flags
372.Pq a set of flags, described below .
373.Pp
374.Bl -tag -compact -width "b offset"
375.It Sy b Ar offset
376Print block pointer at hex offset
377.It Sy c
378Calculate and display checksums
379.It Sy d
380Decompress the block.
381Set environment variable
382.Nm ZDB_NO_ZLE
383to skip zle when guessing.
384.It Sy e
385Byte swap the block
386.It Sy g
387Dump gang block header
388.It Sy i
389Dump indirect block
390.It Sy r
391Dump raw uninterpreted block data
392.It Sy v
393Verbose output for guessing compression algorithm
394.El
395.It Fl s , -io-stats
396Report statistics on
397.Nm zdb
398I/O.
399Display operation counts, bandwidth, and error counts of I/O to the pool from
400.Nm .
401.It Fl S , -simulate-dedup
402Simulate the effects of deduplication, constructing a DDT and then display
403that DDT as with
404.Fl DD .
405.It Fl T , -brt-stats
406Display block reference table (BRT) statistics, including the size of uniques
407blocks cloned, the space saving as a result of cloning, and the saving ratio.
408.It Fl TT
409Display the per-vdev BRT statistics, including total references.
410.It Fl TTT
411Dump the contents of the block reference tables.
412.It Fl u , -uberblock
413Display the current uberblock.
414.El
415.Pp
416Other options:
417.Bl -tag -width Ds
418.It Fl A , -ignore-assertions
419Do not abort should any assertion fail.
420.It Fl AA
421Enable panic recovery, certain errors which would otherwise be fatal are
422demoted to warnings.
423.It Fl AAA
424Do not abort if asserts fail and also enable panic recovery.
425.It Fl e , -exported Ns = Ns Oo Fl p Ar path Oc Ns …
426Operate on an exported pool, not present in
427.Pa /etc/zfs/zpool.cache .
428The
429.Fl p
430flag specifies the path under which devices are to be searched.
431.It Fl x , -dump-blocks Ns = Ns Ar dumpdir
432All blocks accessed will be copied to files in the specified directory.
433The blocks will be placed in sparse files whose name is the same as
434that of the file or device read.
435.Nm
436can be then run on the generated files.
437Note that the
438.Fl bbc
439flags are sufficient to access
440.Pq and thus copy
441all metadata on the pool.
442.It Fl F , -automatic-rewind
443Attempt to make an unreadable pool readable by trying progressively older
444transactions.
445.It Fl G , -dump-debug-msg
446Dump the contents of the zfs_dbgmsg buffer before exiting
447.Nm .
448zfs_dbgmsg is a buffer used by ZFS to dump advanced debug information.
449.It Fl I , -inflight Ns = Ns Ar inflight-I/O-ops
450Limit the number of outstanding checksum I/O operations to the specified value.
451The default value is 200.
452This option affects the performance of the
453.Fl c
454option.
455.It Fl K , -key Ns = Ns Ar key
456Decryption key needed to access an encrypted dataset.
457This will cause
458.Nm
459to attempt to unlock the dataset using the encryption root, key format and other
460encryption parameters on the given dataset.
461.Nm
462can still inspect pool and dataset structures on encrypted datasets without
463unlocking them, but will not be able to access file names and attributes and
464object contents. \fBWARNING:\fP The raw decryption key and any decrypted data
465will be in user memory while
466.Nm
467is running.
468Other user programs may be able to extract it by inspecting
469.Nm
470as it runs.
471Exercise extreme caution when using this option in shared or uncontrolled
472environments.
473.It Fl o , -option Ns = Ns Ar var Ns = Ns Ar value Ns …
474Set the given global libzpool variable to the provided value.
475The value must be an unsigned 32-bit integer.
476Currently only little-endian systems are supported to avoid accidentally setting
477the high 32 bits of 64-bit variables.
478.It Fl P , -parseable
479Print numbers in an unscaled form more amenable to parsing, e.g.\&
480.Sy 1000000
481rather than
482.Sy 1M .
483.It Fl t , -txg Ns = Ns Ar transaction
484Specify the highest transaction to use when searching for uberblocks.
485See also the
486.Fl u
487and
488.Fl l
489options for a means to see the available uberblocks and their associated
490transaction numbers.
491.It Fl U , -cachefile Ns = Ns Ar cachefile
492Use a cache file other than
493.Pa /etc/zfs/zpool.cache .
494.It Fl v , -verbose
495Enable verbosity.
496Specify multiple times for increased verbosity.
497.It Fl V , -verbatim
498Attempt verbatim import.
499This mimics the behavior of the kernel when loading a pool from a cachefile.
500Only usable with
501.Fl e .
502.It Fl X , -extreme-rewind
503Attempt
504.Qq extreme
505transaction rewind, that is attempt the same recovery as
506.Fl F
507but read transactions otherwise deemed too old.
508.It Fl Y , -all-reconstruction
509Attempt all possible combinations when reconstructing indirect split blocks.
510This flag disables the individual I/O deadman timer in order to allow as
511much time as required for the attempted reconstruction.
512.It Fl y , -livelist
513Perform validation for livelists that are being deleted.
514Scans through the livelist and metaslabs, checking for duplicate entries
515and compares the two, checking for potential double frees.
516If it encounters issues, warnings will be printed, but the command will not
517necessarily fail.
518.El
519.Pp
520Specifying a display option more than once enables verbosity for only that
521option, with more occurrences enabling more verbosity.
522.Pp
523If no options are specified, all information about the named pool will be
524displayed at default verbosity.
525.
526.Sh EXAMPLES
527.Ss Example 1 : No Display the configuration of imported pool Ar rpool
528.Bd -literal
529.No # Nm zdb Fl C Ar rpool
530MOS Configuration:
531        version: 28
532        name: 'rpool'
533534.Ed
535.
536.Ss Example 2 : No Display basic dataset information about Ar rpool
537.Bd -literal
538.No # Nm zdb Fl d Ar rpool
539Dataset mos [META], ID 0, cr_txg 4, 26.9M, 1051 objects
540Dataset rpool/swap [ZVOL], ID 59, cr_txg 356, 486M, 2 objects
541542.Ed
543.
544.Ss Example 3 : No Display basic information about object 0 in Ar rpool/export/home
545.Bd -literal
546.No # Nm zdb Fl d Ar rpool/export/home 0
547Dataset rpool/export/home [ZPL], ID 137, cr_txg 1546, 32K, 8 objects
548
549    Object  lvl   iblk   dblk  dsize  lsize   %full  type
550         0    7    16K    16K  15.0K    16K   25.00  DMU dnode
551.Ed
552.
553.Ss Example 4 : No Display the predicted effect of enabling deduplication on Ar rpool
554.Bd -literal
555.No # Nm zdb Fl S Ar rpool
556Simulated DDT histogram:
557
558bucket              allocated                       referenced
559______   ______________________________   ______________________________
560refcnt   blocks   LSIZE   PSIZE   DSIZE   blocks   LSIZE   PSIZE   DSIZE
561------   ------   -----   -----   -----   ------   -----   -----   -----
562     1     694K   27.1G   15.0G   15.0G     694K   27.1G   15.0G   15.0G
563     2    35.0K   1.33G    699M    699M    74.7K   2.79G   1.45G   1.45G
564565dedup = 1.11, compress = 1.80, copies = 1.00, dedup * compress / copies = 2.00
566.Ed
567.
568.Sh SEE ALSO
569.Xr zfs 8 ,
570.Xr zpool 8
571