6 btrfs-check - check or repair a btrfs filesystem
10 *btrfs check* [options] <device>
15 The filesystem checker is used to verify structural integrity of a filesystem
16 and attempt to repair it if requested. It is recommended to unmount the
17 filesystem prior to running the check, but it is possible to start checking a
18 mounted filesystem (see '--force').
20 By default, *btrfs check* will not modify the device but you can reaffirm that
21 by the option '--readonly'.
23 *btrfsck* is an alias of *btrfs check* command and is now deprecated.
25 WARNING: Do not use '--repair' unless you are advised to do so by a developer
26 or an experienced user, and then only after having accepted that no 'fsck'
27 successfully repair all types of filesystem corruption. Eg. some other software
28 or hardware bugs can fatally damage a volume.
30 The structural integrity check verifies if internal filesystem objects or
31 data structures satisfy the constraints, point to the right objects or are
32 correctly connected together.
34 There are several cross checks that can detect wrong reference counts of shared
35 extents, backreferences, missing extents of inodes, directory and inode
38 The amount of memory required can be high, depending on the size of the
39 filesystem, similarly the run time.
41 SAFE OR ADVISORY OPTIONS
42 ------------------------
45 use the first valid set of backup roots stored in the superblock
47 This can be combined with '--super' if some of the superblocks are damaged.
50 verify checksums of data blocks
52 This expects that the filesystem is otherwise OK, and is basically and offline
53 'scrub' but does not repair data from spare copies.
55 --chunk-root <bytenr>::
56 use the given offset 'bytenr' for the chunk tree root
58 -E|--subvol-extents <subvolid>::
59 show extent state for the given subvolume
62 indicate progress at various checking phases
65 verify qgroup accounting and compare against filesystem accounting
67 -r|--tree-root <bytenr>::
68 use the given offset 'bytenr' for the tree root
72 run in read-only mode, this option exists to calm potential panic when users
73 are going to run the checker
75 -s|--super <superblock>::
76 use 'superblock'th superblock copy, valid values are 0, 1 or 2 if the
77 respective superblock offset is within the device size
79 This can be used to use a different starting point if some of the primary
80 superblock is damaged.
82 --clear-space-cache v1|v2::
83 completely wipe all free space cache of given type
85 For free space cache 'v1', the 'clear_cache' kernel mount option only rebuilds
86 the free space cache for block groups that are modified while the filesystem is
87 mounted with that option. Thus, using this option with 'v1' makes it possible
88 to actually clear the entire free space cache.
90 For free space cache 'v2', the 'clear_cache' kernel mount option destroys
91 the entire free space cache. This option, with 'v2' provides an alternative
92 method of clearing the free space cache that doesn't require mounting the
100 enable the repair mode and attempt to fix problems where possible
102 create a new checksum tree and recalculate checksums in all files
104 NOTE: Do not blindly use this option to fix checksum mismatch problems.
107 build the extent tree from scratch
109 NOTE: Do not use unless you know what you're doing.
112 select mode of operation regarding memory and IO
114 The 'MODE' can be one of 'original' and 'lowmem'. The original mode is mostly
115 unoptimized regarding memory consumption and can lead to out-of-memory
116 conditions on large filesystems. The possible workaround is to export the block
117 device over network to a machine with enough memory. The low memory mode is
118 supposed to address the memory consumption, at the cost of increased IO when it
119 needs to re-read blocks when needed. This may increase run time.
121 NOTE: 'lowmem' mode does not work with '--repair' yet, and is still considered
125 allow to work on a mounted filesystem. Note that this should work fine on a
126 quiescent or read-only mounted filesystem but may crash if the device is
127 changed externally, eg. by the kernel module. Repair without mount checks is
128 not supported right now.
132 *btrfs check* returns a zero exit status if it succeeds. Non zero is
133 returned in case of failure.
137 *btrfs* is part of btrfs-progs.
138 Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for