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 27, 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.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 u , -uberblock 407Display the current uberblock. 408.El 409.Pp 410Other options: 411.Bl -tag -width Ds 412.It Fl A , -ignore-assertions 413Do not abort should any assertion fail. 414.It Fl AA 415Enable panic recovery, certain errors which would otherwise be fatal are 416demoted to warnings. 417.It Fl AAA 418Do not abort if asserts fail and also enable panic recovery. 419.It Fl e , -exported Ns = Ns Oo Fl p Ar path Oc Ns … 420Operate on an exported pool, not present in 421.Pa /etc/zfs/zpool.cache . 422The 423.Fl p 424flag specifies the path under which devices are to be searched. 425.It Fl x , -dump-blocks Ns = Ns Ar dumpdir 426All blocks accessed will be copied to files in the specified directory. 427The blocks will be placed in sparse files whose name is the same as 428that of the file or device read. 429.Nm 430can be then run on the generated files. 431Note that the 432.Fl bbc 433flags are sufficient to access 434.Pq and thus copy 435all metadata on the pool. 436.It Fl F , -automatic-rewind 437Attempt to make an unreadable pool readable by trying progressively older 438transactions. 439.It Fl G , -dump-debug-msg 440Dump the contents of the zfs_dbgmsg buffer before exiting 441.Nm . 442zfs_dbgmsg is a buffer used by ZFS to dump advanced debug information. 443.It Fl I , -inflight Ns = Ns Ar inflight-I/O-ops 444Limit the number of outstanding checksum I/O operations to the specified value. 445The default value is 200. 446This option affects the performance of the 447.Fl c 448option. 449.It Fl K , -key Ns = Ns Ar key 450Decryption key needed to access an encrypted dataset. 451This will cause 452.Nm 453to attempt to unlock the dataset using the encryption root, key format and other 454encryption parameters on the given dataset. 455.Nm 456can still inspect pool and dataset structures on encrypted datasets without 457unlocking them, but will not be able to access file names and attributes and 458object contents. \fBWARNING:\fP The raw decryption key and any decrypted data 459will be in user memory while 460.Nm 461is running. 462Other user programs may be able to extract it by inspecting 463.Nm 464as it runs. 465Exercise extreme caution when using this option in shared or uncontrolled 466environments. 467.It Fl o , -option Ns = Ns Ar var Ns = Ns Ar value Ns … 468Set the given global libzpool variable to the provided value. 469The value must be an unsigned 32-bit integer. 470Currently only little-endian systems are supported to avoid accidentally setting 471the high 32 bits of 64-bit variables. 472.It Fl P , -parseable 473Print numbers in an unscaled form more amenable to parsing, e.g.\& 474.Sy 1000000 475rather than 476.Sy 1M . 477.It Fl t , -txg Ns = Ns Ar transaction 478Specify the highest transaction to use when searching for uberblocks. 479See also the 480.Fl u 481and 482.Fl l 483options for a means to see the available uberblocks and their associated 484transaction numbers. 485.It Fl U , -cachefile Ns = Ns Ar cachefile 486Use a cache file other than 487.Pa /etc/zfs/zpool.cache . 488.It Fl v , -verbose 489Enable verbosity. 490Specify multiple times for increased verbosity. 491.It Fl V , -verbatim 492Attempt verbatim import. 493This mimics the behavior of the kernel when loading a pool from a cachefile. 494Only usable with 495.Fl e . 496.It Fl X , -extreme-rewind 497Attempt 498.Qq extreme 499transaction rewind, that is attempt the same recovery as 500.Fl F 501but read transactions otherwise deemed too old. 502.It Fl Y , -all-reconstruction 503Attempt all possible combinations when reconstructing indirect split blocks. 504This flag disables the individual I/O deadman timer in order to allow as 505much time as required for the attempted reconstruction. 506.It Fl y , -livelist 507Perform validation for livelists that are being deleted. 508Scans through the livelist and metaslabs, checking for duplicate entries 509and compares the two, checking for potential double frees. 510If it encounters issues, warnings will be printed, but the command will not 511necessarily fail. 512.El 513.Pp 514Specifying a display option more than once enables verbosity for only that 515option, with more occurrences enabling more verbosity. 516.Pp 517If no options are specified, all information about the named pool will be 518displayed at default verbosity. 519. 520.Sh EXAMPLES 521.Ss Example 1 : No Display the configuration of imported pool Ar rpool 522.Bd -literal 523.No # Nm zdb Fl C Ar rpool 524MOS Configuration: 525 version: 28 526 name: 'rpool' 527 … 528.Ed 529. 530.Ss Example 2 : No Display basic dataset information about Ar rpool 531.Bd -literal 532.No # Nm zdb Fl d Ar rpool 533Dataset mos [META], ID 0, cr_txg 4, 26.9M, 1051 objects 534Dataset rpool/swap [ZVOL], ID 59, cr_txg 356, 486M, 2 objects 535 … 536.Ed 537. 538.Ss Example 3 : No Display basic information about object 0 in Ar rpool/export/home 539.Bd -literal 540.No # Nm zdb Fl d Ar rpool/export/home 0 541Dataset rpool/export/home [ZPL], ID 137, cr_txg 1546, 32K, 8 objects 542 543 Object lvl iblk dblk dsize lsize %full type 544 0 7 16K 16K 15.0K 16K 25.00 DMU dnode 545.Ed 546. 547.Ss Example 4 : No Display the predicted effect of enabling deduplication on Ar rpool 548.Bd -literal 549.No # Nm zdb Fl S Ar rpool 550Simulated DDT histogram: 551 552bucket allocated referenced 553______ ______________________________ ______________________________ 554refcnt blocks LSIZE PSIZE DSIZE blocks LSIZE PSIZE DSIZE 555------ ------ ----- ----- ----- ------ ----- ----- ----- 556 1 694K 27.1G 15.0G 15.0G 694K 27.1G 15.0G 15.0G 557 2 35.0K 1.33G 699M 699M 74.7K 2.79G 1.45G 1.45G 558 … 559dedup = 1.11, compress = 1.80, copies = 1.00, dedup * compress / copies = 2.00 560.Ed 561. 562.Sh SEE ALSO 563.Xr zfs 8 , 564.Xr zpool 8 565