Debian Codegraph @

upstream/mageia-cauldron/man8/btrfs-rescue.8

raw
1 .\" Man page generated from reStructuredText.
2 .
3 .
4 .nr rst2man-indent-level 0
5 .
6 .de1 rstReportMargin
7 \\$1 \\n[an-margin]
8 level \\n[rst2man-indent-level]
9 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
10 -
11 \\n[rst2man-indent0]
12 \\n[rst2man-indent1]
13 \\n[rst2man-indent2]
14 ..
15 .de1 INDENT
16 .\" .rstReportMargin pre:
17 . RS \\$1
18 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
19 . nr rst2man-indent-level +1
20 .\" .rstReportMargin post:
21 ..
22 .de UNINDENT
23 . RE
24 .\" indent \\n[an-margin]
25 .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
26 .nr rst2man-indent-level -1
27 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
28 .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
29 ..
30 .TH "BTRFS-RESCUE" "8" "Mar 10, 2026" "6.19" "BTRFS"
31 .SH NAME
32 btrfs-rescue \- recover a damaged btrfs filesystem
33 .SH SYNOPSIS
34 .sp
35 \fBbtrfs rescue\fP <subcommand> <args>
36 .SH DESCRIPTION
37 .sp
38 A set of commands that are targeting to fix a specific problem and may not
39 suitable for :doc\(gabtrfs\-check\(ga.
40 .SH SUBCOMMAND
41 .INDENT 0.0
42 .TP
43 .B chunk\-recover [options] <device>
44 Recover the chunk tree by scanning the devices
45 .sp
46 \fBOptions\fP
47 .INDENT 7.0
48 .TP
49 .B \-y
50 assume an answer of \fIyes\fP to all questions.
51 .TP
52 .B \-h
53 help.
54 .TP
55 .B \-v
56 (deprecated) alias for global \fI\-v\fP option
57 .UNINDENT
58 .UNINDENT
59 .sp
60 \fBNOTE:\fP
61 .INDENT 0.0
62 .INDENT 3.5
63 Since \fBchunk\-recover\fP will scan the whole device, it will be very
64 slow especially if executed on a large device.
65 .UNINDENT
66 .UNINDENT
67 .INDENT 0.0
68 .TP
69 .B fix\-device\-size <device>
70 Fix device size and super block total bytes values that do not match.
71 .sp
72 Kernel 4.11 starts to check the device size more strictly and this might
73 mismatch the stored value of total bytes. See the exact error message below.
74 Newer kernel will refuse to mount the filesystem where the values do not match.
75 This error is not fatal and can be fixed. This command will fix the device
76 size values if possible.
77 .INDENT 7.0
78 .INDENT 3.5
79 .sp
80 .EX
81 BTRFS error (device sdb): super_total_bytes 92017859088384 mismatch with fs_devices total_rw_bytes 92017859094528
82 .EE
83 .UNINDENT
84 .UNINDENT
85 .sp
86 The mismatch may also exhibit as a kernel warning:
87 .INDENT 7.0
88 .INDENT 3.5
89 .sp
90 .EX
91 WARNING: CPU: 3 PID: 439 at fs/btrfs/ctree.h:1559 btrfs_update_device+0x1c5/0x1d0 [btrfs]
92 .EE
93 .UNINDENT
94 .UNINDENT
95 .TP
96 .B fix\-data\-checksum <device>
97 Selectively fix data checksum mismatch.
98 .sp
99 There is a long existing problem that if a user space program is doing
100 direct IO and modifies the buffer before the write back finished, it
101 can lead to data checksum mismatches.
102 .sp
103 This problem is known but not fixed until upstream release v6.15
104 (backported to older kernels). So it\(aqs possible to hit false data
105 checksum mismatch for any long running btrfs.
106 .sp
107 In that case this program can be utilized to repair such problem.
108 .sp
109 \fBOptions\fP
110 .INDENT 7.0
111 .TP
112 .B \-r|\-\-readonly
113 readonly mode, only scan for and report data checksum mismatches,
114 do not repair
115 .TP
116 .B \-i|\-\-interactive
117 interactive mode, ask for how to repair, ignore the errors by default
118 .TP
119 .B \-m|\-\-mirror <num>
120 use specified mirror to update the checksum item for all corrupted blocks.
121 .sp
122 The value must be >= 1, and if the corrupted block has fewer mirrors than
123 the value, the mirror number will be \fBnum % (num_mirrors + 1)\fP\&.
124 .UNINDENT
125 .UNINDENT
126 .INDENT 0.0
127 .TP
128 .B clear\-ino\-cache <device>
129 Remove leftover items pertaining to the deprecated \fIinode number cache\fP feature.
130 .sp
131 The feature enabled by mount option \fIinode_cache\fP has been completely
132 removed in 5.11 kernel.
133 .TP
134 .B clear\-space\-cache <v1|v2> <device>
135 Completely remove the on\-disk data of free space cache of given version.
136 .sp
137 Especially for v1 free space cache, \fIclear_cache\fP mount option would only
138 remove the cache for updated block groups, the remaining would not be removed.
139 Thus this command is provided to manually clear the free space cache.
140 .UNINDENT
141 .INDENT 0.0
142 .TP
143 .B clear\-uuid\-tree <device>
144 Clear the UUID tree, so that kernel can regenerate it at next read\-write
145 mount.
146 .sp
147 Since kernel v4.16 there are more sanity check performed, and sometimes
148 non\-critical trees like UUID tree can cause problems and reject the mount.
149 In such case, clearing UUID tree may make the filesystem to be mountable again
150 without much risk as it\(aqs built from other trees.
151 See also \fI\%mount option rescan_uuid_tree (in btrfs\-man5)\fP\&.
152 .TP
153 .B super\-recover [options] <device>
154 Recover bad superblocks from good copies.
155 .sp
156 \fBOptions\fP
157 .INDENT 7.0
158 .TP
159 .B \-y
160 assume an answer of \fIyes\fP to all questions.
161 .TP
162 .B \-v
163 (deprecated) alias for global \fI\-v\fP option
164 .UNINDENT
165 .TP
166 .B zero\-log <device>
167 Clear the filesystem log tree.
168 .sp
169 This command will clear the filesystem log tree. This may fix a specific
170 set of problem when the filesystem mount fails during log replay. See below
171 for sample stack traces that may show up in system log.
172 .sp
173 \fBNOTE:\fP
174 .INDENT 7.0
175 .INDENT 3.5
176 Clearing the log may lead to loss of changes that were made
177 since the last transaction commit. This may be up to 30 seconds
178 (default commit period) or less if the commit was implied by
179 other filesystem activity.
180 .UNINDENT
181 .UNINDENT
182 .sp
183 One can determine whether \fBzero\-log\fP is needed according to the kernel
184 backtrace:
185 .INDENT 7.0
186 .INDENT 3.5
187 .sp
188 .EX
189 ? replay_one_dir_item+0xb5/0xb5 [btrfs]
190 ? walk_log_tree+0x9c/0x19d [btrfs]
191 ? btrfs_read_fs_root_no_radix+0x169/0x1a1 [btrfs]
192 ? btrfs_recover_log_trees+0x195/0x29c [btrfs]
193 ? replay_one_dir_item+0xb5/0xb5 [btrfs]
194 ? btree_read_extent_buffer_pages+0x76/0xbc [btrfs]
195 ? open_ctree+0xff6/0x132c [btrfs]
196 .EE
197 .UNINDENT
198 .UNINDENT
199 .sp
200 If the errors are like above, then \fBzero\-log\fP should be used to clear
201 the log and the filesystem may be mounted normally again. The keywords to look
202 for are \(aqopen_ctree\(aq which says that it\(aqs during mount and function names
203 that contain \fIreplay\fP, \fIrecover\fP or \fIlog_tree\fP\&.
204 .UNINDENT
205 .SH EXIT STATUS
206 .sp
207 \fBbtrfs rescue\fP returns a zero exit status if it succeeds. Non zero is
208 returned in case of failure.
209 .SH AVAILABILITY
210 .sp
211 \fBbtrfs\fP is part of btrfs\-progs. Please refer to the documentation at
212 \X'tty: link https://btrfs.readthedocs.io'\fI\%https://btrfs.readthedocs.io\fP\X'tty: link'\&.
213 .SH SEE ALSO
214 .sp
215 \fI\%btrfs\-check(8)\fP,
216 \fI\%btrfs\-scrub(8)\fP,
217 \fI\%mkfs.btrfs(8)\fP
218 .\" Generated by docutils manpage writer.
219 .