xref: /freebsd/sys/contrib/openzfs/man/man8/zdb.8 (revision 1db64f89363c97858961c4df0b7d02f3223723cf)
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.
317.It Fl O , -object-lookups Ns = Ns Ar dataset path
318Also display information about the maximum contiguous free space and the
319percentage of free space in each space map.
320.It Fl MMM
321Display every spacemap record.
322.It Fl N
323Same as
324.Fl d
325but force zdb to interpret the
326.Op Ar dataset Ns | Ns Ar objset-ID
327in
328.Op Ar poolname Ns Op / Ns Ar dataset Ns | Ns Ar objset-ID
329as a numeric objset ID.
330.It Fl O Ar dataset path
331Look up the specified
332.Ar path
333inside of the
334.Ar dataset
335and display its metadata and indirect blocks.
336Specified
337.Ar path
338must be relative to the root of
339.Ar dataset .
340This option can be combined with
341.Fl v
342for increasing verbosity.
343.It Fl r , -copy-object Ns = Ns Ar dataset path destination
344Copy the specified
345.Ar path
346inside of the
347.Ar dataset
348to the specified destination.
349Specified
350.Ar path
351must be relative to the root of
352.Ar dataset .
353This option can be combined with
354.Fl v
355for increasing verbosity.
356.It Xo
357.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
358.Xc
359Read and display a block from the specified device.
360By default the block is displayed as a hex dump, but see the description of the
361.Sy r
362flag, below.
363.Pp
364The block is specified in terms of a colon-separated tuple
365.Ar vdev
366.Pq an integer vdev identifier
367.Ar offset
368.Pq the offset within the vdev
369.Ar size
370.Pq the physical size, or logical size / physical size
371of the block to read and, optionally,
372.Ar flags
373.Pq a set of flags, described below .
374.Pp
375.Bl -tag -compact -width "b offset"
376.It Sy b Ar offset
377Print block pointer at hex offset
378.It Sy c
379Calculate and display checksums
380.It Sy d
381Decompress the block.
382Set environment variable
383.Nm ZDB_NO_ZLE
384to skip zle when guessing.
385.It Sy e
386Byte swap the block
387.It Sy g
388Dump gang block header
389.It Sy i
390Dump indirect block
391.It Sy r
392Dump raw uninterpreted block data
393.It Sy v
394Verbose output for guessing compression algorithm
395.El
396.It Fl s , -io-stats
397Report statistics on
398.Nm zdb
399I/O.
400Display operation counts, bandwidth, and error counts of I/O to the pool from
401.Nm .
402.It Fl S , -simulate-dedup
403Simulate the effects of deduplication, constructing a DDT and then display
404that DDT as with
405.Fl DD .
406.It Fl T , -brt-stats
407Display block reference table (BRT) statistics, including the size of uniques
408blocks cloned, the space saving as a result of cloning, and the saving ratio.
409.It Fl TT
410Display the per-vdev BRT statistics, including total references.
411.It Fl TTT
412Dump the contents of the block reference tables.
413.It Fl u , -uberblock
414Display the current uberblock.
415.El
416.Pp
417Other options:
418.Bl -tag -width Ds
419.It Fl A , -ignore-assertions
420Do not abort should any assertion fail.
421.It Fl AA
422Enable panic recovery, certain errors which would otherwise be fatal are
423demoted to warnings.
424.It Fl AAA
425Do not abort if asserts fail and also enable panic recovery.
426.It Fl e , -exported Ns = Ns Oo Fl p Ar path Oc Ns …
427Operate on an exported pool, not present in
428.Pa /etc/zfs/zpool.cache .
429The
430.Fl p
431flag specifies the path under which devices are to be searched.
432.It Fl x , -dump-blocks Ns = Ns Ar dumpdir
433All blocks accessed will be copied to files in the specified directory.
434The blocks will be placed in sparse files whose name is the same as
435that of the file or device read.
436.Nm
437can be then run on the generated files.
438Note that the
439.Fl bbc
440flags are sufficient to access
441.Pq and thus copy
442all metadata on the pool.
443.It Fl F , -automatic-rewind
444Attempt to make an unreadable pool readable by trying progressively older
445transactions.
446.It Fl G , -dump-debug-msg
447Dump the contents of the zfs_dbgmsg buffer before exiting
448.Nm .
449zfs_dbgmsg is a buffer used by ZFS to dump advanced debug information.
450.It Fl I , -inflight Ns = Ns Ar inflight-I/O-ops
451Limit the number of outstanding checksum I/O operations to the specified value.
452The default value is 200.
453This option affects the performance of the
454.Fl c
455option.
456.It Fl K , -key Ns = Ns Ar key
457Decryption key needed to access an encrypted dataset.
458This will cause
459.Nm
460to attempt to unlock the dataset using the encryption root, key format and other
461encryption parameters on the given dataset.
462.Nm
463can still inspect pool and dataset structures on encrypted datasets without
464unlocking them, but will not be able to access file names and attributes and
465object contents. \fBWARNING:\fP The raw decryption key and any decrypted data
466will be in user memory while
467.Nm
468is running.
469Other user programs may be able to extract it by inspecting
470.Nm
471as it runs.
472Exercise extreme caution when using this option in shared or uncontrolled
473environments.
474.It Fl o , -option Ns = Ns Ar var Ns = Ns Ar value Ns …
475Set the given global libzpool variable to the provided value.
476The value must be an unsigned 32-bit integer.
477Currently only little-endian systems are supported to avoid accidentally setting
478the high 32 bits of 64-bit variables.
479.It Fl P , -parseable
480Print numbers in an unscaled form more amenable to parsing, e.g.\&
481.Sy 1000000
482rather than
483.Sy 1M .
484.It Fl t , -txg Ns = Ns Ar transaction
485Specify the highest transaction to use when searching for uberblocks.
486See also the
487.Fl u
488and
489.Fl l
490options for a means to see the available uberblocks and their associated
491transaction numbers.
492.It Fl U , -cachefile Ns = Ns Ar cachefile
493Use a cache file other than
494.Pa /etc/zfs/zpool.cache .
495.It Fl v , -verbose
496Enable verbosity.
497Specify multiple times for increased verbosity.
498.It Fl V , -verbatim
499Attempt verbatim import.
500This mimics the behavior of the kernel when loading a pool from a cachefile.
501Only usable with
502.Fl e .
503.It Fl X , -extreme-rewind
504Attempt
505.Qq extreme
506transaction rewind, that is attempt the same recovery as
507.Fl F
508but read transactions otherwise deemed too old.
509.It Fl Y , -all-reconstruction
510Attempt all possible combinations when reconstructing indirect split blocks.
511This flag disables the individual I/O deadman timer in order to allow as
512much time as required for the attempted reconstruction.
513.It Fl y , -livelist
514Perform validation for livelists that are being deleted.
515Scans through the livelist and metaslabs, checking for duplicate entries
516and compares the two, checking for potential double frees.
517If it encounters issues, warnings will be printed, but the command will not
518necessarily fail.
519.El
520.Pp
521Specifying a display option more than once enables verbosity for only that
522option, with more occurrences enabling more verbosity.
523.Pp
524If no options are specified, all information about the named pool will be
525displayed at default verbosity.
526.
527.Sh EXAMPLES
528.Ss Example 1 : No Display the configuration of imported pool Ar rpool
529.Bd -literal
530.No # Nm zdb Fl C Ar rpool
531MOS Configuration:
532        version: 28
533        name: 'rpool'
534535.Ed
536.
537.Ss Example 2 : No Display basic dataset information about Ar rpool
538.Bd -literal
539.No # Nm zdb Fl d Ar rpool
540Dataset mos [META], ID 0, cr_txg 4, 26.9M, 1051 objects
541Dataset rpool/swap [ZVOL], ID 59, cr_txg 356, 486M, 2 objects
542543.Ed
544.
545.Ss Example 3 : No Display basic information about object 0 in Ar rpool/export/home
546.Bd -literal
547.No # Nm zdb Fl d Ar rpool/export/home 0
548Dataset rpool/export/home [ZPL], ID 137, cr_txg 1546, 32K, 8 objects
549
550    Object  lvl   iblk   dblk  dsize  lsize   %full  type
551         0    7    16K    16K  15.0K    16K   25.00  DMU dnode
552.Ed
553.
554.Ss Example 4 : No Display the predicted effect of enabling deduplication on Ar rpool
555.Bd -literal
556.No # Nm zdb Fl S Ar rpool
557Simulated DDT histogram:
558
559bucket              allocated                       referenced
560______   ______________________________   ______________________________
561refcnt   blocks   LSIZE   PSIZE   DSIZE   blocks   LSIZE   PSIZE   DSIZE
562------   ------   -----   -----   -----   ------   -----   -----   -----
563     1     694K   27.1G   15.0G   15.0G     694K   27.1G   15.0G   15.0G
564     2    35.0K   1.33G    699M    699M    74.7K   2.79G   1.45G   1.45G
565566dedup = 1.11, compress = 1.80, copies = 1.00, dedup * compress / copies = 2.00
567.Ed
568.
569.Sh SEE ALSO
570.Xr zfs 8 ,
571.Xr zpool 8
572