Debian Codegraph @

upstream/fedora-44/man8/btrfs-rescue.8

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