Debian Codegraph @

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