2014-04-02 08:29:18 +00:00
|
|
|
btrfs-check(8)
|
|
|
|
==============
|
|
|
|
|
|
|
|
NAME
|
|
|
|
----
|
2017-08-31 16:34:37 +00:00
|
|
|
btrfs-check - check or repair a btrfs filesystem
|
2014-04-02 08:29:18 +00:00
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
--------
|
2014-05-19 15:49:35 +00:00
|
|
|
*btrfs check* [options] <device>
|
2014-04-02 08:29:18 +00:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
|
|
|
|
2016-05-06 12:45:57 +00:00
|
|
|
The filesystem checker is used to verify structural integrity of a filesystem
|
2017-08-31 16:34:37 +00:00
|
|
|
and attempt to repair it if requested. It is recommended to unmount the
|
|
|
|
filesystem prior to running the check, but it is possible to start checking a
|
|
|
|
mounted filesystem (see '--force').
|
2016-05-06 12:45:57 +00:00
|
|
|
|
|
|
|
By default, *btrfs check* will not modify the device but you can reaffirm that
|
|
|
|
by the option '--readonly'.
|
2014-04-15 07:04:51 +00:00
|
|
|
|
2014-05-19 15:49:35 +00:00
|
|
|
*btrfsck* is an alias of *btrfs check* command and is now deprecated.
|
2014-04-16 16:33:44 +00:00
|
|
|
|
2017-12-07 20:26:09 +00:00
|
|
|
WARNING: Do not use '--repair' unless you are advised to do so by a developer
|
|
|
|
or an experienced user, and then only after having accepted that no 'fsck'
|
|
|
|
successfully repair all types of filesystem corruption. Eg. some other software
|
|
|
|
or hardware bugs can fatally damage a volume.
|
2016-05-06 12:45:57 +00:00
|
|
|
|
|
|
|
The structural integrity check verifies if internal filesystem objects or
|
|
|
|
data structures satisfy the constraints, point to the right objects or are
|
|
|
|
correctly connected together.
|
|
|
|
|
|
|
|
There are several cross checks that can detect wrong reference counts of shared
|
2017-02-21 23:14:38 +00:00
|
|
|
extents, backreferences, missing extents of inodes, directory and inode
|
2016-05-06 12:45:57 +00:00
|
|
|
connectivity etc.
|
|
|
|
|
|
|
|
The amount of memory required can be high, depending on the size of the
|
2019-11-05 20:58:32 +00:00
|
|
|
filesystem, similarly the run time. Check the modes that can also affect that.
|
|
|
|
|
2016-05-06 12:45:57 +00:00
|
|
|
|
|
|
|
SAFE OR ADVISORY OPTIONS
|
|
|
|
------------------------
|
|
|
|
|
2016-03-09 13:55:11 +00:00
|
|
|
-b|--backup::
|
2016-05-06 12:45:57 +00:00
|
|
|
use the first valid set of backup roots stored in the superblock
|
|
|
|
+
|
|
|
|
This can be combined with '--super' if some of the superblocks are damaged.
|
|
|
|
|
2014-05-28 11:22:40 +00:00
|
|
|
--check-data-csum::
|
2016-01-28 08:00:24 +00:00
|
|
|
verify checksums of data blocks
|
2016-05-06 12:45:57 +00:00
|
|
|
+
|
2020-12-07 21:29:19 +00:00
|
|
|
This expects that the filesystem is otherwise OK, and is basically an offline
|
|
|
|
'scrub' that does not repair data from spare copies.
|
2016-05-06 12:45:57 +00:00
|
|
|
|
|
|
|
--chunk-root <bytenr>::
|
|
|
|
use the given offset 'bytenr' for the chunk tree root
|
|
|
|
|
|
|
|
-E|--subvol-extents <subvolid>::
|
|
|
|
show extent state for the given subvolume
|
|
|
|
|
2015-09-24 06:13:05 +00:00
|
|
|
-p|--progress::
|
|
|
|
indicate progress at various checking phases
|
2016-05-06 12:45:57 +00:00
|
|
|
|
2017-08-24 06:06:41 +00:00
|
|
|
-Q|--qgroup-report::
|
2014-12-18 15:04:10 +00:00
|
|
|
verify qgroup accounting and compare against filesystem accounting
|
2016-05-06 12:45:57 +00:00
|
|
|
|
2016-03-09 13:55:11 +00:00
|
|
|
-r|--tree-root <bytenr>::
|
2016-05-06 12:45:57 +00:00
|
|
|
use the given offset 'bytenr' for the tree root
|
|
|
|
|
|
|
|
--readonly::
|
|
|
|
(default)
|
|
|
|
run in read-only mode, this option exists to calm potential panic when users
|
|
|
|
are going to run the checker
|
|
|
|
|
|
|
|
-s|--super <superblock>::
|
|
|
|
use 'superblock'th superblock copy, valid values are 0, 1 or 2 if the
|
|
|
|
respective superblock offset is within the device size
|
|
|
|
+
|
|
|
|
This can be used to use a different starting point if some of the primary
|
|
|
|
superblock is damaged.
|
|
|
|
|
2016-10-13 09:22:26 +00:00
|
|
|
--clear-space-cache v1|v2::
|
|
|
|
completely wipe all free space cache of given type
|
|
|
|
+
|
2016-11-14 18:43:22 +00:00
|
|
|
For free space cache 'v1', the 'clear_cache' kernel mount option only rebuilds
|
|
|
|
the free space cache for block groups that are modified while the filesystem is
|
|
|
|
mounted with that option. Thus, using this option with 'v1' makes it possible
|
|
|
|
to actually clear the entire free space cache.
|
|
|
|
+
|
2017-12-07 20:26:09 +00:00
|
|
|
For free space cache 'v2', the 'clear_cache' kernel mount option destroys
|
|
|
|
the entire free space cache. This option, with 'v2' provides an alternative
|
2016-11-14 18:43:22 +00:00
|
|
|
method of clearing the free space cache that doesn't require mounting the
|
|
|
|
filesystem.
|
2016-10-13 09:22:26 +00:00
|
|
|
|
2020-12-14 13:49:35 +00:00
|
|
|
--clear-ino-cache::
|
|
|
|
remove leftover items pertaining to the deprecated inode map feature
|
|
|
|
|
2016-10-13 09:22:26 +00:00
|
|
|
|
2016-05-06 12:45:57 +00:00
|
|
|
DANGEROUS OPTIONS
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
--repair::
|
|
|
|
enable the repair mode and attempt to fix problems where possible
|
2019-11-05 20:48:42 +00:00
|
|
|
+
|
|
|
|
NOTE: there's a warning and 10 second delay when this option is run without
|
|
|
|
'--force' to give users a chance to think twice before running repair, the
|
|
|
|
warnings in documentation have shown to be insufficient
|
|
|
|
|
2016-05-06 12:45:57 +00:00
|
|
|
--init-csum-tree::
|
|
|
|
create a new checksum tree and recalculate checksums in all files
|
|
|
|
+
|
|
|
|
NOTE: Do not blindly use this option to fix checksum mismatch problems.
|
|
|
|
|
|
|
|
--init-extent-tree::
|
|
|
|
build the extent tree from scratch
|
|
|
|
+
|
|
|
|
NOTE: Do not use unless you know what you're doing.
|
2014-04-02 08:29:18 +00:00
|
|
|
|
2019-11-05 20:58:32 +00:00
|
|
|
--mode <MODE>::
|
2016-08-17 17:33:24 +00:00
|
|
|
select mode of operation regarding memory and IO
|
2016-04-24 07:47:12 +00:00
|
|
|
+
|
2019-11-05 20:58:32 +00:00
|
|
|
The 'MODE' can be one of:
|
|
|
|
+
|
|
|
|
'original'::::
|
|
|
|
The metadata are read into memory and verified, thus the requirements are high
|
|
|
|
on large filesystems and can even lead to out-of-memory conditions. The
|
|
|
|
possible workaround is to export the block device over network to a machine
|
|
|
|
with enough memory.
|
|
|
|
'lowmem'::::
|
|
|
|
This mode is supposed to address the high memory consumption at the cost of
|
|
|
|
increased IO when it needs to re-read blocks. This may increase run time.
|
|
|
|
+
|
2016-08-17 17:33:24 +00:00
|
|
|
NOTE: 'lowmem' mode does not work with '--repair' yet, and is still considered
|
|
|
|
experimental.
|
2016-04-24 07:47:12 +00:00
|
|
|
|
2017-08-31 16:34:37 +00:00
|
|
|
--force::
|
2018-03-16 00:39:09 +00:00
|
|
|
allow work on a mounted filesystem. Note that this should work fine on a
|
2017-08-31 16:34:37 +00:00
|
|
|
quiescent or read-only mounted filesystem but may crash if the device is
|
|
|
|
changed externally, eg. by the kernel module. Repair without mount checks is
|
|
|
|
not supported right now.
|
2019-11-05 20:48:42 +00:00
|
|
|
+
|
2019-11-05 20:58:32 +00:00
|
|
|
This option also skips the delay and warning in the repair mode (see
|
|
|
|
'--repair').
|
2017-08-31 16:34:37 +00:00
|
|
|
|
2014-04-02 08:29:18 +00:00
|
|
|
EXIT STATUS
|
|
|
|
-----------
|
2014-09-19 01:49:59 +00:00
|
|
|
*btrfs check* returns a zero exit status if it succeeds. Non zero is
|
2014-04-02 08:29:18 +00:00
|
|
|
returned in case of failure.
|
|
|
|
|
|
|
|
AVAILABILITY
|
|
|
|
------------
|
2014-05-19 16:04:26 +00:00
|
|
|
*btrfs* is part of btrfs-progs.
|
2014-04-02 08:29:18 +00:00
|
|
|
Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
|
|
|
|
further details.
|
|
|
|
|
|
|
|
SEE ALSO
|
|
|
|
--------
|
|
|
|
`mkfs.btrfs`(8),
|
|
|
|
`btrfs-scrub`(8),
|
|
|
|
`btrfs-rescue`(8)
|