1BTRFS-CHECK(8) Btrfs Manual BTRFS-CHECK(8)
2
3
4
6 btrfs-check - check or repair a btrfs filesystem
7
9 btrfs check [options] <device>
10
12 The filesystem checker is used to verify structural integrity of a
13 filesystem and attempt to repair it if requested. It is recommended to
14 unmount the filesystem prior to running the check, but it is possible
15 to start checking a mounted filesystem (see --force).
16
17 By default, btrfs check will not modify the device but you can reaffirm
18 that by the option --readonly.
19
20 btrfsck is an alias of btrfs check command and is now deprecated.
21
22 Warning
23 Do not use --repair unless you are advised to do so by a developer
24 or an experienced user, and then only after having accepted that no
25 fsck successfully repair all types of filesystem corruption. Eg.
26 some other software or hardware bugs can fatally damage a volume.
27
28 The structural integrity check verifies if internal filesystem objects
29 or data structures satisfy the constraints, point to the right objects
30 or are correctly connected together.
31
32 There are several cross checks that can detect wrong reference counts
33 of shared extents, backreferences, missing extents of inodes, directory
34 and inode connectivity etc.
35
36 The amount of memory required can be high, depending on the size of the
37 filesystem, similarly the run time. Check the modes that can also
38 affect that.
39
41 -b|--backup
42 use the first valid set of backup roots stored in the superblock
43
44 This can be combined with --super if some of the superblocks are
45 damaged.
46
47 --check-data-csum
48 verify checksums of data blocks
49
50 This expects that the filesystem is otherwise OK, and is basically
51 an offline scrub that does not repair data from spare copies.
52
53 --chunk-root <bytenr>
54 use the given offset bytenr for the chunk tree root
55
56 -E|--subvol-extents <subvolid>
57 show extent state for the given subvolume
58
59 -p|--progress
60 indicate progress at various checking phases
61
62 -Q|--qgroup-report
63 verify qgroup accounting and compare against filesystem accounting
64
65 -r|--tree-root <bytenr>
66 use the given offset bytenr for the tree root
67
68 --readonly
69 (default) run in read-only mode, this option exists to calm
70 potential panic when users are going to run the checker
71
72 -s|--super <superblock>
73 use 'superblock’th superblock copy, valid values are 0, 1 or 2 if
74 the respective superblock offset is within the device size
75
76 This can be used to use a different starting point if some of the
77 primary superblock is damaged.
78
79 --clear-space-cache v1|v2
80 completely wipe all free space cache of given type
81
82 For free space cache v1, the clear_cache kernel mount option only
83 rebuilds the free space cache for block groups that are modified
84 while the filesystem is mounted with that option. Thus, using this
85 option with v1 makes it possible to actually clear the entire free
86 space cache.
87
88 For free space cache v2, the clear_cache kernel mount option
89 destroys the entire free space cache. This option, with v2 provides
90 an alternative method of clearing the free space cache that doesn’t
91 require mounting the filesystem.
92
93 --clear-ino-cache
94 remove leftover items pertaining to the deprecated inode map
95 feature
96
98 --repair
99 enable the repair mode and attempt to fix problems where possible
100
101 Note
102 there’s a warning and 10 second delay when this option is run
103 without --force to give users a chance to think twice before
104 running repair, the warnings in documentation have shown to be
105 insufficient
106
107 --init-csum-tree
108 create a new checksum tree and recalculate checksums in all files
109
110 Note
111 Do not blindly use this option to fix checksum mismatch
112 problems.
113
114 --init-extent-tree
115 build the extent tree from scratch
116
117 Note
118 Do not use unless you know what you’re doing.
119
120 --mode <MODE>
121 select mode of operation regarding memory and IO
122
123 The MODE can be one of:
124
125 original
126 The metadata are read into memory and verified, thus the
127 requirements are high on large filesystems and can even lead to
128 out-of-memory conditions. The possible workaround is to export
129 the block device over network to a machine with enough memory.
130
131 lowmem
132 This mode is supposed to address the high memory consumption at
133 the cost of increased IO when it needs to re-read blocks. This
134 may increase run time.
135
136 Note
137 lowmem mode does not work with --repair yet, and is still
138 considered experimental.
139
140 --force
141 allow work on a mounted filesystem. Note that this should work fine
142 on a quiescent or read-only mounted filesystem but may crash if the
143 device is changed externally, eg. by the kernel module. Repair
144 without mount checks is not supported right now.
145
146 This option also skips the delay and warning in the repair mode
147 (see --repair).
148
150 btrfs check returns a zero exit status if it succeeds. Non zero is
151 returned in case of failure.
152
154 btrfs is part of btrfs-progs. Please refer to the btrfs wiki
155 http://btrfs.wiki.kernel.org for further details.
156
158 mkfs.btrfs(8), btrfs-scrub(8), btrfs-rescue(8)
159
160
161
162Btrfs v5.12.1 05/13/2021 BTRFS-CHECK(8)