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