1BTRFS-CHECK(8) Btrfs Manual BTRFS-CHECK(8)
2
3
4
6 btrfs-check - check or repair a btrfs filesystem
7
9 btrfs check [options] <device>
10
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. Eg.
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.
38
40 -b|--backup
41 use the first valid set of backup roots stored in the superblock
42
43 This can be combined with --super if some of the superblocks are
44 damaged.
45
46 --check-data-csum
47 verify checksums of data blocks
48
49 This expects that the filesystem is otherwise OK, and is basically
50 and offline scrub but does not repair data from spare copies.
51
52 --chunk-root <bytenr>
53 use the given offset bytenr for the chunk tree root
54
55 -E|--subvol-extents <subvolid>
56 show extent state for the given subvolume
57
58 -p|--progress
59 indicate progress at various checking phases
60
61 -Q|--qgroup-report
62 verify qgroup accounting and compare against filesystem accounting
63
64 -r|--tree-root <bytenr>
65 use the given offset bytenr for the tree root
66
67 --readonly
68 (default) run in read-only mode, this option exists to calm
69 potential panic when users are going to run the checker
70
71 -s|--super <superblock>
72 use 'superblock’th superblock copy, valid values are 0, 1 or 2 if
73 the respective superblock offset is within the device size
74
75 This can be used to use a different starting point if some of the
76 primary superblock is damaged.
77
78 --clear-space-cache v1|v2
79 completely wipe all free space cache of given type
80
81 For free space cache v1, the clear_cache kernel mount option only
82 rebuilds the free space cache for block groups that are modified
83 while the filesystem is mounted with that option. Thus, using this
84 option with v1 makes it possible to actually clear the entire free
85 space cache.
86
87 For free space cache v2, the clear_cache kernel mount option
88 destroys the entire free space cache. This option, with v2 provides
89 an alternative method of clearing the free space cache that doesn’t
90 require mounting the filesystem.
91
93 --repair
94 enable the repair mode and attempt to fix problems where possible
95
96 --init-csum-tree
97 create a new checksum tree and recalculate checksums in all files
98
99 Note
100 Do not blindly use this option to fix checksum mismatch
101 problems.
102
103 --init-extent-tree
104 build the extent tree from scratch
105
106 Note
107 Do not use unless you know what you’re doing.
108
109 --mode=MODE
110 select mode of operation regarding memory and IO
111
112 The MODE can be one of original and lowmem. The original mode is
113 mostly unoptimized regarding memory consumption and can lead to
114 out-of-memory conditions on large filesystems. The possible
115 workaround is to export the block device over network to a machine
116 with enough memory. The low memory mode is supposed to address the
117 memory consumption, at the cost of increased IO when it needs to
118 re-read blocks when needed. This may increase run time.
119
120 Note
121 lowmem mode does not work with --repair yet, and is still
122 considered experimental.
123
124 --force
125 allow work on a mounted filesystem. Note that this should work fine
126 on a quiescent or read-only mounted filesystem but may crash if the
127 device is changed externally, eg. by the kernel module. Repair
128 without mount checks is not supported right now.
129
131 btrfs check returns a zero exit status if it succeeds. Non zero is
132 returned in case of failure.
133
135 btrfs is part of btrfs-progs. Please refer to the btrfs wiki
136 http://btrfs.wiki.kernel.org for further details.
137
139 mkfs.btrfs(8), btrfs-scrub(8), btrfs-rescue(8)
140
141
142
143Btrfs v5.1 05/17/2019 BTRFS-CHECK(8)