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

NAME

6       btrfs-check - check or repair a btrfs filesystem
7

SYNOPSIS

9       btrfs check [options] <device>
10

DESCRIPTION

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. E.g.
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 af‐
38       fect that.
39

SAFE OR ADVISORY OPTIONS

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 basi‐
51              cally an offline scrub that does  not  repair  data  from  spare
52              copies.
53
54       --chunk-root <bytenr>
55              use the given offset bytenr for the chunk tree root
56
57       -E|--subvol-extents <subvolid>
58              show extent state for the given subvolume
59
60       -p|--progress
61              indicate progress at various checking phases
62
63       -Q|--qgroup-report
64              verify qgroup accounting and compare against filesystem account‐
65              ing
66
67       -r|--tree-root <bytenr>
68              use the given offset 'bytenr' for the tree root
69
70       --readonly
71              (default) run in read-only mode, this option exists to calm  po‐
72              tential panic when users are going to run the checker
73
74       -s|--super <N>
75              use  Nth  superblock copy, valid values are 0, 1 or 2 if the re‐
76              spective superblock offset is within the device size
77
78              This can be used to use a different starting point  if  some  of
79              the primary superblock is damaged.
80
81       --clear-space-cache v1|v2
82              completely remove the free space cache of the given version
83
84              See also the clear_cache mount option.
85
86              WARNING:
87                 This   option   is   deprecated,   please  use  btrfs  rescue
88                 clear-space-cache instead, this option would  be  removed  in
89                 the future eventually.
90
91       --clear-ino-cache
92              remove  leftover  items pertaining to the deprecated inode cache
93              feature
94
95              WARNING:
96                 This  option  is  deprecated,   please   use   btrfs   rescue
97                 clear-ino-cache  instead, this option would be removed in the
98                 future eventually.
99

DANGEROUS OPTIONS

101       --repair
102              enable the repair mode and attempt to fix problems where  possi‐
103              ble
104
105              NOTE:
106                 There's a warning and 10 second delay when this option is run
107                 without --force to give users a chance to think twice  before
108                 running  repair,  the warnings in documentation have shown to
109                 be insufficient.
110
111       --init-csum-tree
112              create a new checksum tree  and  recalculate  checksums  in  all
113              files
114
115              WARNING:
116                 Do not blindly use this option to fix checksum mismatch prob‐
117                 lems.
118
119       --init-extent-tree
120              build the extent tree from scratch
121
122              WARNING:
123                 Do not use unless you know what you're doing.
124
125       --mode <MODE>
126              select mode of operation regarding memory and IO
127
128              The MODE can be one of:
129
130              original
131                     The metadata are read into memory and verified, thus  the
132                     requirements  are  high on large filesystems and can even
133                     lead to out-of-memory  conditions.   The  possible  work‐
134                     around  is  to  export the block device over network to a
135                     machine with enough memory.
136
137              lowmem This mode is supposed to address the high memory consump‐
138                     tion at the cost of increased IO when it needs to re-read
139                     blocks.  This may increase run time.
140
141              NOTE:
142                 lowmem mode does not work with --repair  yet,  and  is  still
143                 considered experimental.
144
145       --force
146              allow  work  on a mounted filesystem and skip mount checks. Note
147              that this should work fine on a quiescent or  read-only  mounted
148              filesystem  but  may  crash if the device is changed externally,
149              e.g. by the kernel module.
150
151              NOTE:
152                 It is possible to run with --repair but on a mounted filesys‐
153                 tem  that  will  most  likely lead to a corruption unless the
154                 filesystem is in a quiescent state which may not be  possible
155                 to guarantee.
156
157              This  option also skips the delay and warning in the repair mode
158              (see --repair).
159

EXIT STATUS

161       btrfs check returns a zero exit status if it succeeds. Non zero is  re‐
162       turned in case of failure.
163

AVAILABILITY

165       btrfs  is  part  of  btrfs-progs.  Please refer to the documentation at
166       https://btrfs.readthedocs.io.
167

SEE ALSO

169       mkfs.btrfs(8), btrfs-scrub(8), btrfs-rescue(8)
170
171
172
173
1746.6.2                            Nov 24, 2023                   BTRFS-CHECK(8)
Impressum