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

NAME

6       btrfs-device - manage devices of btrfs filesystems
7

SYNOPSIS

9       btrfs device <subcommand> <args>
10

DESCRIPTION

12       The  btrfs  device command group is used to manage devices of the btrfs
13       filesystems.
14

DEVICE MANAGEMENT

SUBCOMMAND

17       add [-Kf] <device> [<device>...] <path>
18              Add device(s) to the filesystem identified by path.
19
20              If applicable, a whole device discard (TRIM) operation  is  per‐
21              formed  prior  to  adding  the  device.  A  device with existing
22              filesystem detected by blkid(8) will prevent device addition and
23              has to be forced. Alternatively the filesystem can be wiped from
24              the device using eg. the wipefs(8) tool.
25
26              The operation is instant and does not affect existing data.  The
27              operation  merely  adds  the device to the filesystem structures
28              and creates some block groups headers.
29
30              Options
31
32              -K|--nodiscard
33                     do not perform discard (TRIM) by default
34
35              -f|--force
36                     force overwrite  of  existing  filesystem  on  the  given
37                     disk(s)
38
39              --enqueue
40                     wait if there's another exclusive operation running, oth‐
41                     erwise continue
42
43       remove [options] <device>|<devid> [<device>|<devid>...] <path>
44              Remove device(s) from a filesystem identified by <path>
45
46              Device removal must satisfy the profile  constraints,  otherwise
47              the  command  fails.  The  filesystem  must be converted to pro‐
48              file(s) that would allow the removal. This can typically  happen
49              when going down from 2 devices to 1 and using the RAID1 profile.
50              See the section TYPICAL USECASES.
51
52              The operation can take long as it needs to move  all  data  from
53              the device.
54
55              It  is  possible to delete the device that was used to mount the
56              filesystem. The device entry in the mount table will be replaced
57              by another device name with the lowest device id.
58
59              If  the  filesystem  is  mounted in degraded mode (-o degraded),
60              special term missing can be used for device. In that  case,  the
61              first  device  that is described by the filesystem metadata, but
62              not present at the mount time will be removed.
63
64              NOTE:
65                 In most cases, there is only one missing device  in  degraded
66                 mode, otherwise mount fails. If there are two or more devices
67                 missing (e.g. possible in RAID6), you need specify missing as
68                 many  times as the number of missing devices to remove all of
69                 them.
70
71              Options
72
73              --enqueue
74                     wait if there's another exclusive operation running, oth‐
75                     erwise continue
76
77       delete <device>|<devid> [<device>|<devid>...] <path>
78              Alias of remove kept for backward compatibility
79
80       ready <device>
81              Wait  until  all  devices  of  a  multiple-device filesystem are
82              scanned and registered within the kernel module. This is to pro‐
83              vide  a  way for automatic filesystem mounting tools to wait be‐
84              fore the mount can start. The device scan is  only  one  of  the
85              preconditions  and the mount can fail for other reasons.  Normal
86              users usually do not need this command and may safely ignore it.
87
88       scan [options] [<device> [<device>...]]
89              Scan devices for a btrfs filesystem and register them  with  the
90              kernel  module.  This allows mounting multiple-device filesystem
91              by specifying just one from the whole group.
92
93              If no devices are passed, all block devices that  blkid  reports
94              to contain btrfs are scanned.
95
96              The  options  --all-devices  or  -d can be used as a fallback in
97              case blkid is not available.  If used, behavior is the  same  as
98              if no devices are passed.
99
100              The  command  can  be run repeatedly. Devices that have been al‐
101              ready registered remain as such.  Reloading  the  kernel  module
102              will drop this information. There's an alternative way of mount‐
103              ing multiple-device filesystem without the need for prior  scan‐
104              ning. See the mount option device.
105
106              Options
107
108              -d|--all-devices
109                     Enumerate  and register all devices, use as a fallback in
110                     case blkid is not available.
111
112              -u|--forget
113                     Unregister a given device or all stale devices if no path
114                     is  given, the device must be unmounted otherwise it's an
115                     error.
116
117       stats [options] <path>|<device>
118              Read and print the device IO error statistics for all devices of
119              the given filesystem identified by path or for a single device>.
120              The filesystem must be mounted.  See section *DEVICE  STATS  for
121              more information about the reported statistics and the meaning.
122
123              Options
124
125              -z|--reset
126                     Print the stats and reset the values to zero afterwards.
127
128              -c|--check
129                     Check  if  the  stats are all zeros and return 0 if it is
130                     so. Set bit 6 of the return code if any of the statistics
131                     is  no-zero. The error values is 65 if reading stats from
132                     at least one device failed, otherwise it's 64.
133
134       usage [options] <path> [<path>...]::
135              Show detailed information about internal allocations on devices.
136
137              The level of detail can differ if the command  is  run  under  a
138              regular  or the root user (due to use of restricted ioctls). The
139              first example below is for normal user  (warning  included)  and
140              the next one with root on the same filesystem:
141
142                 WARNING: cannot read detailed chunk info, per-device usage will not be shown, run as root
143                 /dev/sdc1, ID: 1
144                    Device size:           931.51GiB
145                    Device slack:              0.00B
146                    Unallocated:           931.51GiB
147
148                 /dev/sdc1, ID: 1
149                    Device size:           931.51GiB
150                    Device slack:              0.00B
151                    Data,single:           641.00GiB
152                    Data,RAID0/3:            1.00GiB
153                    Metadata,single:        19.00GiB
154                    System,single:          32.00MiB
155                    Unallocated:           271.48GiB
156
157Device  size  --  size of the device as seen by the filesystem
158                (may be different than actual device size)
159
160Device slack -- portion of device not used by  the  filesystem
161                but  still available in the physical space provided by the de‐
162                vice, eg.  after a device shrink
163
164Data,single, Metadata,single,  System,single  --  in  general,
165                list  of block group type (Data, Metadata, System) and profile
166                (single, RAID1, ...) allocated on the device
167
168Data,RAID0/3    --    in    particular,    striped    profiles
169                RAID0/RAID10/RAID5/RAID6  with  the number of devices on which
170                the stripes are allocated, multiple occurrences  of  the  same
171                profile can appear in case a new device has been added and all
172                new available stripes have been used for writes
173
174Unallocated -- remaining space that the filesystem  can  still
175                use for new block groups
176
177              Options
178
179              -b|--raw
180                     raw numbers in bytes, without the B suffix
181
182              -h|--human-readable
183                     print  human friendly numbers, base 1024, this is the de‐
184                     fault
185
186              -H     print human friendly numbers, base 1000
187
188              --iec  select the 1024 base for the following options, according
189                     to the IEC standard
190
191              --si   select the 1000 base for the following options, according
192                     to the SI standard
193
194              -k|--kbytes
195                     show sizes in KiB, or kB with --si
196
197              -m|--mbytes
198                     show sizes in MiB, or MB with --si
199
200              -g|--gbytes
201                     show sizes in GiB, or GB with --si
202
203              -t|--tbytes
204                     show sizes in TiB, or TB with --si
205
206              If conflicting options are passed, the  last  one  takes  prece‐
207              dence.
208

DEVICE STATS

210       The  device  stats  keep persistent record of several error classes re‐
211       lated to doing IO. The current values are printed at mount time and up‐
212       dated during filesystem lifetime or from a scrub run.
213
214          $ btrfs device stats /dev/sda3
215          [/dev/sda3].write_io_errs   0
216          [/dev/sda3].read_io_errs    0
217          [/dev/sda3].flush_io_errs   0
218          [/dev/sda3].corruption_errs 0
219          [/dev/sda3].generation_errs 0
220
221       write_io_errs
222              Failed  writes  to  the block devices, means that the layers be‐
223              neath the filesystem were not able to satisfy the write request.
224
225       read_io_errors
226              Read request analogy to write_io_errs.
227
228       flush_io_errs
229              Number of failed writes with the FLUSH flag set. The flushing is
230              a  method  of  forcing a particular order between write requests
231              and is crucial for implementing crash consistency.  In  case  of
232              btrfs, all the metadata blocks must be permanently stored on the
233              block device before the superblock is written.
234
235       corruption_errs
236              A block checksum mismatched or a corrupted metadata  header  was
237              found.
238
239       generation_errs
240              The  block  generation  does  not  match the expected value (eg.
241              stored in the parent node).
242
243       Since kernel 5.14 the device stats are also available in  textual  form
244       in /sys/fs/btrfs/FSID/devinfo/DEVID/error_stats.
245

EXIT STATUS

247       btrfs device returns a zero exit status if it succeeds. Non zero is re‐
248       turned in case of failure.
249
250       If the -c option is used, btrfs device stats will add 64  to  the  exit
251       status if any of the error counters is non-zero.
252

AVAILABILITY

254       btrfs  is  part  of  btrfs-progs.   Please  refer  to  the  btrfs  wiki
255       http://btrfs.wiki.kernel.org for further details.
256

SEE ALSO

258       mkfs.btrfs(8), btrfs-replace(8), btrfs-balance(8)
259
261       2022
262
263
264
265
2665.18                             May 25, 2022                  BTRFS-DEVICE(8)
Impressum