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