149c9bd98ab2484e599377f88efb56237815b4e5
[platform/upstream/btrfs-progs.git] / Documentation / btrfs-scrub.asciidoc
1 btrfs-scrub(8)
2 ==============
3
4 NAME
5 ----
6 btrfs-scrub - scrub btrfs filesystem, verify block checksums
7
8 SYNOPSIS
9 --------
10 *btrfs scrub* <subcommand> <args>
11
12 DESCRIPTION
13 -----------
14 *btrfs scrub* is used to scrub a btrfs filesystem, which will read all data
15 and metadata blocks from all devices and verify checksums. Automatically repair
16 corrupted blocks if there's a correct copy available.
17
18 NOTE: Scrub is not a filesystem checker (fsck) and does not verify nor repair
19 structural damage in the filesystem.
20
21 The user is supposed to run it manually or via a periodic system service. The
22 recommended period is a month but could be less. The estimated device bandwidth
23 utilization is about 80% on an idle filesystem. The IO priority class is by
24 default 'idle' so background scrub should not interfere with normal filesystem
25 operation significantly.
26
27 The scrubbing status is recorded in '/var/lib/btrfs/' in textual files named
28 'scrub.status.UUID' for a filesystem identified by the given UUID. (An
29 itermediate progress is communicated through a named pipe in file
30 'scrub.progress.UUID' in the same directory.) The status file is updated
31 periodically every 5 seconds. A resumed scrub will continue from the last
32 saved position.
33
34 SUBCOMMAND
35 ----------
36 *cancel* <path>|<device>::
37 If a scrub is running on the filesystem identified by 'path' cancel it.
38 +
39 If a 'device' is specified, the corresponding filesystem is found and
40 *btrfs scrub cancel* behaves as if it was called on that filesystem.
41
42 *resume* [-BdqrR] [-c <ioprio_class> -n <ioprio_classdata>] <path>|<device>::
43 Resume a cancelled or interrupted scrub on the filesystem identified by
44 'path' or on a given 'device'.
45 +
46 Does not start a new scrub if the last scrub finished successfully.
47 +
48 `Options`
49 +
50 see *scrub start*.
51
52 *start* [-BdqrRf] [-c <ioprio_class> -n <ioprio_classdata>] <path>|<device>::
53 Start a scrub on all devices of the filesystem identified by 'path' or on
54 a single 'device'. If a scrub is already running, the new one fails.
55 +
56 Without options, scrub is started as a background process.
57 +
58 The default IO priority of scrub is the idle class. The priority can be
59 configured similar to the `ionice`(1) syntax using '-c' and '-n' options.
60 +
61 `Options`
62 +
63 -B::::
64 do not background and print scrub statistics when finished
65 -d::::
66 print separate statistics for each device of the filesystem ('-B' only) at the end
67 -q::::
68 be quiet, omit error messages and statistics
69 -r::::
70 run in read-only mode, do not attempt to correct anything, can be run on a read-only
71 filesystem
72 -R::::
73 print raw statistics per-device instead of a summary
74 -c <ioprio_class>::::
75 set IO priority class (see `ionice`(1) manpage)
76 -n <ioprio_classdata>::::
77 set IO priority classdata (see `ionice`(1) manpage)
78 -f::::
79 force starting new scrub even if a scrub is already running,
80 this can useful when scrub status file is damaged and reports a running
81 scrub although it is not, but should not normally be necessary
82
83 *status* [-d] <path>|<device>::
84 Show status of a running scrub for the filesystem identified by 'path' or
85 for the specified 'device'.
86 +
87 If no scrub is running, show statistics of the last finished or cancelled scrub
88 for that filesystem or device.
89 +
90 `Options`
91 +
92 -d::::
93 print separate statistics for each device of the filesystem
94
95 EXIT STATUS
96 -----------
97 *btrfs scrub* returns a zero exit status if it succeeds. Non zero is
98 returned in case of failure:
99
100 1::::
101 scrub couldn't be performed
102 2::::
103 there is nothing to resume
104 3::::
105 scrub found uncorrectable errors
106
107 AVAILABILITY
108 ------------
109 *btrfs* is part of btrfs-progs.
110 Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
111 further details.
112
113 SEE ALSO
114 --------
115 `mkfs.btrfs`(8),
116 `ionice`(1)