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