1BTRFS-RESCUE(8)                      BTRFS                     BTRFS-RESCUE(8)
2
3
4

NAME

6       btrfs-rescue - recover a damaged btrfs filesystem
7

SYNOPSIS

9       btrfs rescue <subcommand> <args>
10

DESCRIPTION

12       btrfs rescue is used to try to recover a damaged btrfs filesystem.
13

SUBCOMMAND

15       chunk-recover [options] <device>
16              Recover the chunk tree by scanning the devices
17
18              Options
19
20              -y     assume an answer of yes to all questions.
21
22              -h     help.
23
24              -v     (deprecated) alias for global -v option
25
26       NOTE:
27          Since chunk-recover will scan the whole device, it will be very slow
28          especially executed on a large device.
29
30       fix-device-size <device>
31              fix device size and super block total bytes values that  do  not
32              match
33
34              Kernel  4.11  starts  to check the device size more strictly and
35              this might mismatch the stored value of total bytes. See the ex‐
36              act  error message below.  Newer kernel will refuse to mount the
37              filesystem where the values do not match.  This error is not fa‐
38              tal  and  can  be  fixed.  This command will fix the device size
39              values if possible.
40
41                 BTRFS error (device sdb): super_total_bytes 92017859088384 mismatch with fs_devices total_rw_bytes 92017859094528
42
43              The mismatch may also exhibit as a kernel warning:
44
45                 WARNING: CPU: 3 PID: 439 at fs/btrfs/ctree.h:1559 btrfs_update_device+0x1c5/0x1d0 [btrfs]
46
47       clear-ino-cache <device>
48              Remove leftover items pertaining to the deprecated  inode  cache
49              feature.
50
51              The  inode cache feature (enabled by mount option "inode_cache")
52              has been completely removed in 5.11 kernel.
53
54       clear-space-cache <v1|v2> <device>
55              Completely remove the on-disk data of free space cache of  given
56              version.
57
58              Especially  for  v1  free  space cache, clear_cache mount option
59              would only remove the cache for updated block  groups,  the  re‐
60              maining  would not be removed.  Thus this command is provided to
61              manually clear the free space cache.
62
63       clear-uuid-tree <device>
64              Clear UUID tree, so that  kernel  can  re-generate  it  at  next
65              read-write mount.
66
67              Since  kernel  v4.16  there are more sanity check performed, and
68              sometimes non-critical trees like UUID tree can  cause  problems
69              and reject the mount.  In such case, clearing UUID tree may make
70              the filesystem to be mountable again without much risk  as  it's
71              built from other trees.
72
73       super-recover [options] <device>
74              Recover bad superblocks from good copies.
75
76              Options
77
78              -y     assume an answer of yes to all questions.
79
80              -v     (deprecated) alias for global -v option
81
82       zero-log <device>
83              clear the filesystem log tree
84
85              This  command will clear the filesystem log tree. This may fix a
86              specific set of problem when the filesystem mount fails  due  to
87              the  log replay. See below for sample stack traces that may show
88              up in system log.
89
90              The common case where this happens was fixed a long time ago, so
91              it  is  unlikely  that you will see this particular problem, but
92              the command is kept around.
93
94              NOTE:
95                 Clearing the log may lead to loss of changes that  were  made
96                 since  the last transaction commit. This may be up to 30 sec‐
97                 onds (default commit period) or less if the  commit  was  im‐
98                 plied by other filesystem activity.
99
100              One  can  determine  whether zero-log is needed according to the
101              kernel backtrace:
102
103                 ? replay_one_dir_item+0xb5/0xb5 [btrfs]
104                 ? walk_log_tree+0x9c/0x19d [btrfs]
105                 ? btrfs_read_fs_root_no_radix+0x169/0x1a1 [btrfs]
106                 ? btrfs_recover_log_trees+0x195/0x29c [btrfs]
107                 ? replay_one_dir_item+0xb5/0xb5 [btrfs]
108                 ? btree_read_extent_buffer_pages+0x76/0xbc [btrfs]
109                 ? open_ctree+0xff6/0x132c [btrfs]
110
111              If the errors are like above, then zero-log should  be  used  to
112              clear  the log and the filesystem may be mounted normally again.
113              The keywords to look for are 'open_ctree' which says  that  it's
114              during  mount and function names that contain replay, recover or
115              log_tree.
116

EXIT STATUS

118       btrfs rescue returns a zero exit status if it succeeds. Non zero is re‐
119       turned in case of failure.
120

AVAILABILITY

122       btrfs  is  part  of  btrfs-progs.  Please refer to the documentation at
123       https://btrfs.readthedocs.io.
124

SEE ALSO

126       btrfs-check(8), btrfs-scrub(8), mkfs.btrfs(8)
127
128
129
130
1316.6.2                            Nov 24, 2023                  BTRFS-RESCUE(8)
Impressum