Debian Codegraph @

upstream/opensuse-leap-16-1/man8/mkfs.btrfs.8

raw
1 '\" t
2 .\" Man page generated from reStructuredText.
3 .
4 .
5 .nr rst2man-indent-level 0
6 .
7 .de1 rstReportMargin
8 \\$1 \\n[an-margin]
9 level \\n[rst2man-indent-level]
10 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
11 -
12 \\n[rst2man-indent0]
13 \\n[rst2man-indent1]
14 \\n[rst2man-indent2]
15 ..
16 .de1 INDENT
17 .\" .rstReportMargin pre:
18 . RS \\$1
19 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
20 . nr rst2man-indent-level +1
21 .\" .rstReportMargin post:
22 ..
23 .de UNINDENT
24 . RE
25 .\" indent \\n[an-margin]
26 .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
27 .nr rst2man-indent-level -1
28 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
29 .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
30 ..
31 .TH "MKFS.BTRFS" "8" "Mar 26, 2025" "6.14" "BTRFS"
32 .SH NAME
33 mkfs.btrfs \- create a btrfs filesystem
34 .SH SYNOPSIS
35 .sp
36 \fBmkfs.btrfs\fP [options] <device> [<device>...]
37 .SH DESCRIPTION
38 .sp
39 \fBmkfs.btrfs\fP is used to create the btrfs filesystem on a single or multiple
40 devices. The \fIdevice\fP is typically a block device but can be a file\-backed image
41 as well. Multiple devices are grouped by UUID of the filesystem.
42 .sp
43 Before mounting such filesystem, the kernel module must know all the devices
44 either via preceding execution of \fBbtrfs device scan\fP or using the \fIdevice\fP
45 mount option. See section \fI\%MULTIPLE DEVICES\fP
46 for more details.
47 .sp
48 The default block group profiles for data and metadata depend on number of
49 devices and possibly other factors. It\(aqs recommended to use specific profiles
50 but the defaults should be OK and allowing future conversions to other profiles.
51 Please see options \fI\-d\fP and \fI\-m\fP for further details and \fI\%btrfs\-balance(8)\fP for
52 the profile conversion post mkfs.
53 .SH OPTIONS
54 .INDENT 0.0
55 .TP
56 .B \-b|\-\-byte\-count <size>
57 Specify the size of each device as seen by the filesystem. If not set,
58 the entire device size is used. The total filesystem size will be the sum
59 of all device sizes, for a single device filesystem the option
60 effectively specifies the size of the filesystem.
61 .UNINDENT
62 .INDENT 0.0
63 .TP
64 .BI \-\-csum \ <type>\fR,\fB \ \-\-checksum \ <type>
65 Specify the checksum algorithm. Default is \fIcrc32c\fP\&. Valid values are \fIcrc32c\fP,
66 \fIxxhash\fP, \fIsha256\fP or \fIblake2\fP\&. To mount such filesystem kernel must support the
67 checksums as well. See section \fI\%CHECKSUM ALGORITHMS\fP
68 in \fI\%btrfs(5)\fP\&.
69 .UNINDENT
70 .INDENT 0.0
71 .TP
72 .B \-d|\-\-data <profile>
73 Specify the profile for the data block groups. Valid values are \fIraid0\fP,
74 \fIraid1\fP, \fIraid1c3\fP, \fIraid1c4\fP, \fIraid5\fP, \fIraid6\fP, \fIraid10\fP or \fIsingle\fP or \fIdup\fP
75 (case does not matter).
76 .sp
77 See section \fI\%DUP PROFILES ON A SINGLE DEVICE\fP
78 for more details.
79 .sp
80 On multiple devices, the default was \fIraid0\fP until version 5.7, while it is
81 \fIsingle\fP since version 5.8. You can still select \fIraid0\fP manually, but it was not
82 suitable as default.
83 .TP
84 .B \-m|\-\-metadata <profile>
85 Specify the profile for the metadata block groups.
86 Valid values are \fIraid0\fP, \fIraid1\fP, \fIraid1c3\fP, \fIraid1c4\fP, \fIraid5\fP, \fIraid6\fP,
87 \fIraid10\fP, \fIsingle\fP or \fIdup\fP (case does not matter).
88 .sp
89 Default on a single device filesystem is \fIDUP\fP and is recommended for metadata
90 in general. The duplication might not be necessary in some use cases and it\(aqs
91 up to the user to changed that at mkfs time or later. This depends on hardware
92 that could potentially deduplicate the blocks again but this cannot be detected
93 at mkfs time.
94 .sp
95 \fBNOTE:\fP
96 .INDENT 7.0
97 .INDENT 3.5
98 Up to version 5.14 there was a detection of a SSD device (more precisely
99 if it\(aqs a rotational device, determined by the contents of file
100 \fB/sys/block/DEV/queue/rotational\fP) that used to select \fIsingle\fP\&. This has
101 changed in version 5.15 to be always \fIdup\fP\&.
102 .sp
103 Note that the rotational status can be arbitrarily set by the underlying block
104 device driver and may not reflect the true status (network block device, memory\-backed
105 SCSI devices, real block device behind some additional device mapper layer,
106 etc). It\(aqs recommended to always set the options \fI\-\-data/\-\-metadata\fP to avoid
107 confusion and unexpected results.
108 .sp
109 See section \fI\%DUP PROFILES ON A SINGLE DEVICE\fP
110 for more details.
111 .UNINDENT
112 .UNINDENT
113 .sp
114 On multiple devices the default is \fIraid1\fP\&.
115 .UNINDENT
116 .INDENT 0.0
117 .TP
118 .B \-M|\-\-mixed
119 Normally the data and metadata block groups are isolated. The \fImixed\fP mode
120 will remove the isolation and store both types in the same block group type.
121 This helps to utilize the free space regardless of the purpose and is suitable
122 for small devices. The separate allocation of block groups leads to a situation
123 where the space is reserved for the other block group type, is not available for
124 allocation and can lead to ENOSPC state.
125 .sp
126 The recommended size for the mixed mode is for filesystems less than 1GiB. The
127 soft recommendation is to use it for filesystems smaller than 5GiB. The mixed
128 mode may lead to degraded performance on larger filesystems, but is otherwise
129 usable, even on multiple devices.
130 .sp
131 The \fInodesize\fP and \fIsectorsize\fP must be equal, and the block group types must
132 match.
133 .sp
134 \fBNOTE:\fP
135 .INDENT 7.0
136 .INDENT 3.5
137 Versions up to 4.2.x forced the mixed mode for devices smaller than 1GiB.
138 This has been removed in 4.3+ as it caused some usability issues.
139 .sp
140 Mixed profile cannot be used together with other profiles. It can only
141 be set at creation time. Conversion to or from mixed profile is not
142 implemented.
143 .UNINDENT
144 .UNINDENT
145 .TP
146 .B \-n|\-\-nodesize <size>
147 Specify the nodesize, the tree block size in which btrfs stores metadata. The
148 default value is 16KiB (16384) or the page size, whichever is bigger. Must be a
149 multiple of the sectorsize and a power of 2, but not larger than 64KiB (65536).
150 Leafsize always equals nodesize and the options are aliases.
151 .sp
152 Smaller node size increases fragmentation but leads to taller b\-trees which in
153 turn leads to lower locking contention. Higher node sizes give better packing
154 and less fragmentation at the cost of more expensive memory operations while
155 updating the metadata blocks.
156 .sp
157 \fBNOTE:\fP
158 .INDENT 7.0
159 .INDENT 3.5
160 Versions up to 3.11 set the nodesize to 4KiB.
161 .UNINDENT
162 .UNINDENT
163 .TP
164 .B \-s|\-\-sectorsize <size>
165 Specify the sectorsize, the minimum data block allocation unit.
166 .sp
167 \fBNOTE:\fP
168 .INDENT 7.0
169 .INDENT 3.5
170 Versions prior to 6.7 set the sectorsize matching the host CPU
171 page size, starting in 6.7 this is 4KiB for cross\-architecture
172 compatibility. Please read more about the \fI\%subpage block size support\fP
173 and \fI\%its status\fP\&.
174 .UNINDENT
175 .UNINDENT
176 .sp
177 By default, the value is 4KiB, but it can be manually set to match the
178 system page size (e.g. using command \fBgetconf PAGE_SIZE\fP).
179 However, if the sector size is different from the page
180 size, the resulting filesystem may not be mountable by the current
181 kernel, apart from the default 4KiB. Hence, using this option is not
182 advised unless you intend to mount it on a system with the suitable
183 page size.
184 .sp
185 In experimental build the size 2K (2048) is also allowed and needs
186 kernel that also allows that value, then it works in the subpage mode.
187 .TP
188 .B \-L|\-\-label <string>
189 Specify a label for the filesystem. The \fIstring\fP should be less than 256
190 bytes and must not contain newline characters.
191 .TP
192 .B \-K|\-\-nodiscard
193 Do not perform whole device TRIM operation on devices that are capable of that.
194 This does not affect discard/trim operation when the filesystem is mounted.
195 Please see the mount option \fIdiscard\fP for that in \fI\%btrfs(5)\fP\&.
196 .TP
197 .B \-r|\-\-rootdir <rootdir>
198 Populate the toplevel subvolume with files from \fIrootdir\fP\&. This does not
199 require root permissions to write the new files or to mount the filesystem.
200 .sp
201 Directories can be created as subvolumes, see also option \fI\-\-subvol\fP\&.
202 Hardlinks are detected and created in the filesystem image.
203 .sp
204 \fBNOTE:\fP
205 .INDENT 7.0
206 .INDENT 3.5
207 This option may enlarge the image or file to ensure it\(aqs big enough to
208 contain the files from \fIrootdir\fP\&. Since version 4.14.1 the filesystem size is
209 not minimized. Please see option \fI\-\-shrink\fP if you need that functionality.
210 .UNINDENT
211 .UNINDENT
212 .TP
213 .B \-\-compress <algo>[:<level>]
214 Try to compress files when using \fI\-\-rootdir\fP\&. Supported values for \fIalgo\fP are
215 \fIno\fP (the default), \fIzstd\fP, \fIlzo\fP or \fIzlib\fP\&. The optional value \fIlevel\fP is a
216 compression level, 1..15 for \fIzstd\fP, 1..9 for \fIzlib\fP\&.
217 .sp
218 It is recommended to use the highest level to achieve maximum space savings.
219 Compression at mkfs time is not as constrained as in kernel where it\(aqs
220 desirable to use less CPU load. Otherwise the default level is 3.
221 .sp
222 As with the kernel, \fBmkfs.btrfs\fP won\(aqt write compressed extents when
223 they would be larger than the uncompressed versions, and will set file attribute
224 \fINOCOMPRESS\fP if its beginning is found to be incompressible.
225 .sp
226 \fBNOTE:\fP
227 .INDENT 7.0
228 .INDENT 3.5
229 The support for ZSTD and LZO is a compile\-time option, please check
230 the output of \fBmkfs.btrfs \-\-version\fP for the actual support.
231 .UNINDENT
232 .UNINDENT
233 .TP
234 .B \-u|\-\-subvol <type>:<subdir>
235 Specify that \fIsubdir\fP is to be created as a subvolume rather than a regular
236 directory. The option \fI\-\-rootdir\fP must also be specified, and \fIsubdir\fP must be an
237 existing subdirectory within it. This option can be specified multiple times.
238 .sp
239 The \fItype\fP is an optional additional modifier. Valid choices are:
240 .INDENT 7.0
241 .IP \(bu 2
242 \fIdefault\fP: create as default subvolume
243 .IP \(bu 2
244 \fIro\fP: create as read\-only subvolume
245 .IP \(bu 2
246 \fIrw\fP: create as read\-write subvolume (the default)
247 .IP \(bu 2
248 \fIdefault\-ro\fP: create as read\-only default subvolume
249 .UNINDENT
250 .sp
251 Only one of \fIdefault\fP and \fIdefault\-ro\fP may be specified.
252 .sp
253 If you wish to create a subvolume with a name containing a colon and you don\(aqt
254 want this to be parsed as containing a modifier, you can prefix the path with \fB\&./\fP:
255 .INDENT 7.0
256 .INDENT 3.5
257 .sp
258 .EX
259 $ mkfs.btrfs \-\-rootdir dir \-\-subvol ./ro:subdir /dev/loop0
260 .EE
261 .UNINDENT
262 .UNINDENT
263 .sp
264 If there are hardlinks inside \fIrootdir\fP and \fIsubdir\fP will split the
265 subvolumes, like the following case:
266 .INDENT 7.0
267 .INDENT 3.5
268 .sp
269 .EX
270 rootdir/
271 |\- hardlink1
272 |\- hardlink2
273 |\- subdir/ <\- will be a subvolume
274 |\- hardlink3
275 .EE
276 .UNINDENT
277 .UNINDENT
278 .sp
279 In that case we cannot create \fBhardlink3\fP as hardlinks of
280 \fBhardlink1\fP and \fBhardlink2\fP because \fBhardlink3\fP will
281 be inside a new subvolume.
282 .UNINDENT
283 .INDENT 0.0
284 .TP
285 .B \-\-shrink
286 Shrink the filesystem to its minimal size, only works with \fI\-\-rootdir\fP option.
287 .sp
288 If the destination block device is a regular file, this option will also
289 truncate the file to the minimal size. Otherwise it will reduce the filesystem
290 available space. Extra space will not be usable unless the filesystem is
291 mounted and resized using \fBbtrfs filesystem resize\fP\&.
292 .sp
293 \fBNOTE:\fP
294 .INDENT 7.0
295 .INDENT 3.5
296 Prior to version 4.14.1, the shrinking was done automatically.
297 .UNINDENT
298 .UNINDENT
299 .UNINDENT
300 .INDENT 0.0
301 .TP
302 .B \-O|\-\-features <feature1>[,<feature2>...]
303 A list of filesystem features turned on at mkfs time. Not all features are
304 supported by old kernels. To disable a feature, prefix it with \fI^\fP\&.
305 .sp
306 See section \fI\%FILESYSTEM FEATURES\fP
307 for more details. To see all available features that
308 \fBmkfs.btrfs\fP supports run:
309 .INDENT 7.0
310 .INDENT 3.5
311 .sp
312 .EX
313 $ mkfs.btrfs \-O list\-all
314 .EE
315 .UNINDENT
316 .UNINDENT
317 .TP
318 .B \-f|\-\-force
319 Forcibly overwrite the block devices when an existing filesystem is detected.
320 By default, \fBmkfs.btrfs\fP will utilize \fIlibblkid\fP to check for any known
321 filesystem on the devices. Alternatively you can use the \fBwipefs\fP utility
322 to clear the devices.
323 .TP
324 .B \-q|\-\-quiet
325 Print only error or warning messages. Options \fI\-\-features\fP or \fI\-\-help\fP are unaffected.
326 Resets any previous effects of \fI\-\-verbose\fP\&.
327 .TP
328 .B \-U|\-\-uuid <UUID>
329 Create the filesystem with the given \fIUUID\fP\&. For a single\-device filesystem,
330 you can duplicate the UUID. However, for a multi\-device filesystem, the UUID
331 must not already exist on any currently present filesystem.
332 .UNINDENT
333 .INDENT 0.0
334 .TP
335 .BI \-\-device\-uuid \ <UUID>
336 Create the filesystem with the given device\-uuid \fIUUID\fP (also known as
337 UUID_SUB in \fBblkid\fP). For a single device filesystem, you can
338 duplicate the device\-uuid. However, used for a multi\-device filesystem
339 this option will not work at the moment.
340 .UNINDENT
341 .INDENT 0.0
342 .TP
343 .B \-v|\-\-verbose
344 Increase verbosity level, default is 1.
345 .TP
346 .B \-V|\-\-version
347 Print the \fBmkfs.btrfs\fP version, builtin features and exit.
348 .UNINDENT
349 .INDENT 0.0
350 .TP
351 .B \-\-help
352 Print help.
353 .UNINDENT
354 .SH DEPRECATED OPTIONS
355 .INDENT 0.0
356 .TP
357 .B \-R|\-\-runtime\-features <feature1>[,<feature2>...]
358 Removed in 6.3, was used to specify features not affecting on\-disk format.
359 Now all such features are merged into \fI\-O|\-\-features\fP option. The option
360 \-R will stay for backward compatibility.
361 .UNINDENT
362 .SH SIZE UNITS
363 .sp
364 The default unit is \fIbyte\fP\&. All size parameters accept suffixes in the 1024
365 base. The recognized suffixes are: \fIk\fP, \fIm\fP, \fIg\fP, \fIt\fP, \fIp\fP, \fIe\fP, both uppercase
366 and lowercase.
367 .SH MULTIPLE DEVICES
368 .sp
369 Before mounting a multiple device filesystem, the kernel module must know the
370 association of the block devices that are attached to the filesystem UUID.
371 .sp
372 There is typically no action needed from the user. On a system that utilizes a
373 udev\-like daemon, any new block device is automatically registered. The rules
374 call \fBbtrfs device scan\fP\&.
375 .sp
376 The same command can be used to trigger the device scanning if the btrfs kernel
377 module is reloaded (naturally all previous information about the device
378 registration is lost).
379 .sp
380 Another possibility is to use the mount options \fIdevice\fP to specify the list of
381 devices to scan at the time of mount.
382 .INDENT 0.0
383 .INDENT 3.5
384 .sp
385 .EX
386 # mount \-o device=/dev/sdb,device=/dev/sdc /dev/sda /mnt
387 .EE
388 .UNINDENT
389 .UNINDENT
390 .sp
391 \fBNOTE:\fP
392 .INDENT 0.0
393 .INDENT 3.5
394 This means only scanning, if the devices do not exist in the system,
395 mount will fail anyway. This can happen on systems without initramfs/initrd and
396 root partition created with RAID1/10/5/6 profiles. The mount action can happen
397 before all block devices are discovered. The waiting is usually done on the
398 initramfs/initrd systems.
399 .UNINDENT
400 .UNINDENT
401 .sp
402 \fBWARNING:\fP
403 .INDENT 0.0
404 .INDENT 3.5
405 RAID5/6 has known problems and should not be used in production.
406 .UNINDENT
407 .UNINDENT
408 .SH FILESYSTEM FEATURES
409 .sp
410 Features that can be enabled during creation time. See also \fI\%btrfs(5)\fP section
411 \fI\%FILESYSTEM FEATURES\fP\&.
412 .INDENT 0.0
413 .TP
414 .B mixed\-bg
415 (kernel support since 2.6.37)
416 .sp
417 mixed data and metadata block groups, also set by option \fI\-\-mixed\fP
418 .UNINDENT
419 .INDENT 0.0
420 .TP
421 .B extref
422 (default since btrfs\-progs 3.12, kernel support since 3.7)
423 .sp
424 increased hardlink limit per file in a directory to 65536, older kernels
425 supported a varying number of hardlinks depending on the sum of all file name
426 sizes that can be stored into one metadata block
427 .TP
428 .B raid56
429 (kernel support since 3.9)
430 .sp
431 extended format for RAID5/6, also enabled if RAID5 or RAID6 block groups
432 are selected
433 .UNINDENT
434 .INDENT 0.0
435 .TP
436 .B skinny\-metadata
437 (default since btrfs\-progs 3.18, kernel support since 3.10)
438 .sp
439 reduced\-size metadata for extent references, saves a few percent of metadata
440 .UNINDENT
441 .INDENT 0.0
442 .TP
443 .B no\-holes
444 (default since btrfs\-progs 5.15, kernel support since 3.14)
445 .sp
446 improved representation of file extents where holes are not explicitly
447 stored as an extent, saves a few percent of metadata if sparse files are used
448 .TP
449 .B zoned
450 (kernel support since 5.12)
451 .sp
452 zoned mode, data allocation and write friendly to zoned/SMR/ZBC/ZNS devices,
453 see \fI\%ZONED MODE\fP in
454 \fI\%btrfs(5)\fP, the mode is automatically selected when a
455 zoned device is detected
456 .TP
457 .B quota
458 (kernel support since 3.4)
459 .sp
460 Enable quota support (qgroups). The qgroup accounting will be consistent,
461 can be used together with \fI\-\-rootdir\fP\&. See also \fI\%btrfs\-quota(8)\fP\&.
462 .UNINDENT
463 .INDENT 0.0
464 .TP
465 .B free\-space\-tree
466 (default since btrfs\-progs 5.15, kernel support since 4.5)
467 .sp
468 Enable the free space tree (mount option \fIspace_cache=v2\fP) for persisting the
469 free space cache in a b\-tree. This is built on top of the COW mechanism
470 and has better performance than v1.
471 .sp
472 Offline conversion from filesystems that don\(aqt have this feature
473 enabled at \fImkfs\fP time is possible, see \fI\%btrfstune(8)\fP\&.
474 .sp
475 Online conversion can be done by mounting with \fBspace_cache=v2\fP, this
476 is sufficient to be done one time.
477 .UNINDENT
478 .INDENT 0.0
479 .TP
480 .B block\-group\-tree
481 (kernel support since 6.1)
482 .sp
483 Enable a dedicated b\-tree for block group items, this greatly reduces
484 mount time for large filesystems due to better data locality that
485 avoids seeking. On rotational devices the \fIlarge\fP size is considered
486 starting from the 2\-4TiB. Can be used on other types of devices (SSD,
487 NVMe, ...) as well.
488 .sp
489 Offline conversion from filesystems that don\(aqt have this feature
490 enabled at \fImkfs\fP time is possible, see \fI\%btrfstune(8)\fP\&. Online
491 conversion is not possible.
492 .UNINDENT
493 .INDENT 0.0
494 .TP
495 .B raid\-stripe\-tree
496 (kernel support since 6.7, CONFIG_BTRFS_DEBUG/CONFIG_BTRFS_EXPERIMENTAL)
497 .sp
498 Separate tree for logical file extent mapping where the physical mapping
499 may not match on multiple devices. This is now used in zoned mode to
500 implement RAID0/RAID1* profiles, but can be used in non\-zoned mode as
501 well. The support for RAID56 is in development and will eventually
502 fix the problems with the current implementation. This is a backward
503 incompatible feature and has to be enabled at mkfs time.
504 .sp
505 \fBNOTE:\fP
506 .INDENT 7.0
507 .INDENT 3.5
508 Due to the status of implementation it is enabled only in
509 builds with CONFIG_BTRFS_DEBUG/CONFIG_BTRFS_EXPERIMENTAL.
510 Support by the kernel module can be found in the sysfs feature
511 list.
512 .UNINDENT
513 .UNINDENT
514 .TP
515 .B squota
516 (kernel support since 6.7)
517 .sp
518 Enable simple quota accounting (squotas). This is an alternative to
519 qgroups with a smaller performance impact but no notion of shared vs.
520 exclusive usage.
521 .UNINDENT
522 .SH BLOCK GROUPS, CHUNKS, RAID
523 .sp
524 The highlevel organizational units of a filesystem are block groups of three types:
525 data, metadata and system.
526 .INDENT 0.0
527 .TP
528 .B DATA
529 store data blocks and nothing else
530 .TP
531 .B METADATA
532 store internal metadata in b\-trees, can store file data if they fit into the
533 inline limit
534 .TP
535 .B SYSTEM
536 store structures that describe the mapping between the physical devices and the
537 linear logical space representing the filesystem
538 .UNINDENT
539 .sp
540 Other terms commonly used:
541 .INDENT 0.0
542 .TP
543 .B block group, chunk
544 a logical range of space of a given profile, stores data, metadata or both;
545 sometimes the terms are used interchangeably
546 .sp
547 A typical size of metadata block group is 256MiB (filesystem smaller than
548 50GiB) and 1GiB (larger than 50GiB), for data it\(aqs 1GiB. The system block group
549 size is a few megabytes.
550 .TP
551 .B RAID
552 a block group profile type that utilizes RAID\-like features on multiple
553 devices: striping, mirroring, parity
554 .TP
555 .B profile
556 when used in connection with block groups refers to the allocation strategy
557 and constraints, see the section \fI\%PROFILES\fP for more details
558 .UNINDENT
559 .SH PROFILES
560 .sp
561 There are the following block group types available:
562 .TS
563 box center;
564 l|l|l|l|l|l.
565 T{
566 Profiles
567 T} T{
568 Redundancy
569 .sp
570 Copies
571 T} T{
572 Redundancy
573 .sp
574 Parity
575 T} T{
576 Redundancy
577 .sp
578 Striping
579 T} T{
580 Space utilization
581 T} T{
582 Min/max devices
583 T}
584 _
585 T{
586 single
587 T} T{
588 1
589 T} T{
590 T} T{
591 T} T{
592 100%
593 T} T{
594 1/any
595 T}
596 _
597 T{
598 DUP
599 T} T{
600 2 / 1 device
601 T} T{
602 T} T{
603 T} T{
604 50%
605 T} T{
606 1/any (see note 1)
607 T}
608 _
609 T{
610 RAID0
611 T} T{
612 1
613 T} T{
614 T} T{
615 1 to N
616 T} T{
617 100%
618 T} T{
619 1/any (see note 5)
620 T}
621 _
622 T{
623 RAID1
624 T} T{
625 2
626 T} T{
627 T} T{
628 T} T{
629 50%
630 T} T{
631 2/any
632 T}
633 _
634 T{
635 RAID1C3
636 T} T{
637 3
638 T} T{
639 T} T{
640 T} T{
641 33%
642 T} T{
643 3/any
644 T}
645 _
646 T{
647 RAID1C4
648 T} T{
649 4
650 T} T{
651 T} T{
652 T} T{
653 25%
654 T} T{
655 4/any
656 T}
657 _
658 T{
659 RAID10
660 T} T{
661 2
662 T} T{
663 T} T{
664 1 to N
665 T} T{
666 50%
667 T} T{
668 2/any (see note 5)
669 T}
670 _
671 T{
672 RAID5
673 T} T{
674 1
675 T} T{
676 1
677 T} T{
678 2 to N\-1
679 T} T{
680 (N\-1)/N
681 T} T{
682 2/any (see note 2)
683 T}
684 _
685 T{
686 RAID6
687 T} T{
688 1
689 T} T{
690 2
691 T} T{
692 3 to N\-2
693 T} T{
694 (N\-2)/N
695 T} T{
696 3/any (see note 3)
697 T}
698 .TE
699 .sp
700 \fBWARNING:\fP
701 .INDENT 0.0
702 .INDENT 3.5
703 It\(aqs not recommended to create filesystems with RAID0/1/10/5/6
704 profiles on partitions from the same device. Neither redundancy nor
705 performance will be improved.
706 .UNINDENT
707 .UNINDENT
708 .sp
709 \fINote 1:\fP DUP may exist on more than 1 device if it starts on a single device and
710 another one is added. Since version 4.5.1, \fBmkfs.btrfs\fP will let you create DUP
711 on multiple devices without restrictions.
712 .sp
713 \fINote 2:\fP It\(aqs not recommended to use 2 devices with RAID5. In that case,
714 parity stripe will contain the same data as the data stripe, making RAID5
715 degraded to RAID1 with more overhead.
716 .sp
717 \fINote 3:\fP It\(aqs also not recommended to use 3 devices with RAID6, unless you
718 want to get effectively 3 copies in a RAID1\-like manner (but not exactly that).
719 .sp
720 \fINote 4:\fP Since kernel 5.5 it\(aqs possible to use RAID1C3 as replacement for
721 RAID6, higher space cost but reliable.
722 .sp
723 \fINote 5:\fP Since kernel 5.15 it\(aqs possible to use (mount, convert profiles)
724 RAID0 on one device and RAID10 on two devices.
725 .SS PROFILE LAYOUT
726 .sp
727 For the following examples, assume devices numbered by 1, 2, 3 and 4, data or
728 metadata blocks A, B, C, D, with possible stripes e.g. A1, A2 that would be
729 logically A, etc. For parity profiles PA and QA are parity and syndrome,
730 associated with the given stripe. The simple layouts single or DUP are left
731 out. Actual physical block placement on devices depends on current state of
732 the free/allocated space and may appear random. All devices are assumed to be
733 present at the time of the blocks would have been written.
734 .SS RAID1
735 .TS
736 box center;
737 l|l|l|l.
738 T{
739 device 1
740 T} T{
741 device 2
742 T} T{
743 device 3
744 T} T{
745 device 4
746 T}
747 _
748 T{
749 A
750 T} T{
751 D
752 T} T{
753 T} T{
754 T}
755 _
756 T{
757 B
758 T} T{
759 T} T{
760 T} T{
761 C
762 T}
763 _
764 T{
765 C
766 T} T{
767 T} T{
768 T} T{
769 T}
770 _
771 T{
772 D
773 T} T{
774 A
775 T} T{
776 B
777 T} T{
778 T}
779 .TE
780 .SS RAID1C3
781 .TS
782 box center;
783 l|l|l|l.
784 T{
785 device 1
786 T} T{
787 device 2
788 T} T{
789 device 3
790 T} T{
791 device 4
792 T}
793 _
794 T{
795 A
796 T} T{
797 A
798 T} T{
799 D
800 T} T{
801 T}
802 _
803 T{
804 B
805 T} T{
806 T} T{
807 B
808 T} T{
809 T}
810 _
811 T{
812 C
813 T} T{
814 T} T{
815 A
816 T} T{
817 C
818 T}
819 _
820 T{
821 D
822 T} T{
823 D
824 T} T{
825 C
826 T} T{
827 B
828 T}
829 .TE
830 .SS RAID0
831 .TS
832 box center;
833 l|l|l|l.
834 T{
835 device 1
836 T} T{
837 device 2
838 T} T{
839 device 3
840 T} T{
841 device 4
842 T}
843 _
844 T{
845 A2
846 T} T{
847 C3
848 T} T{
849 A3
850 T} T{
851 C2
852 T}
853 _
854 T{
855 B1
856 T} T{
857 A1
858 T} T{
859 D2
860 T} T{
861 B3
862 T}
863 _
864 T{
865 C1
866 T} T{
867 D3
868 T} T{
869 B4
870 T} T{
871 D1
872 T}
873 _
874 T{
875 D4
876 T} T{
877 B2
878 T} T{
879 C4
880 T} T{
881 A4
882 T}
883 .TE
884 .SS RAID5
885 .TS
886 box center;
887 l|l|l|l.
888 T{
889 device 1
890 T} T{
891 device 2
892 T} T{
893 device 3
894 T} T{
895 device 4
896 T}
897 _
898 T{
899 A2
900 T} T{
901 C3
902 T} T{
903 A3
904 T} T{
905 C2
906 T}
907 _
908 T{
909 B1
910 T} T{
911 A1
912 T} T{
913 D2
914 T} T{
915 B3
916 T}
917 _
918 T{
919 C1
920 T} T{
921 D3
922 T} T{
923 PB
924 T} T{
925 D1
926 T}
927 _
928 T{
929 PD
930 T} T{
931 B2
932 T} T{
933 PC
934 T} T{
935 PA
936 T}
937 .TE
938 .SS RAID6
939 .TS
940 box center;
941 l|l|l|l.
942 T{
943 device 1
944 T} T{
945 device 2
946 T} T{
947 device 3
948 T} T{
949 device 4
950 T}
951 _
952 T{
953 A2
954 T} T{
955 QC
956 T} T{
957 QA
958 T} T{
959 C2
960 T}
961 _
962 T{
963 B1
964 T} T{
965 A1
966 T} T{
967 D2
968 T} T{
969 QB
970 T}
971 _
972 T{
973 C1
974 T} T{
975 QD
976 T} T{
977 PB
978 T} T{
979 D1
980 T}
981 _
982 T{
983 PD
984 T} T{
985 B2
986 T} T{
987 PC
988 T} T{
989 PA
990 T}
991 .TE
992 .SH DUP PROFILES ON A SINGLE DEVICE
993 .sp
994 The mkfs utility will let the user create a filesystem with profiles that write
995 the logical blocks to 2 physical locations. Whether there are really 2
996 physical copies highly depends on the underlying device type.
997 .sp
998 For example, a SSD drive can remap the blocks internally to a single copy\-\-thus
999 deduplicating them. This negates the purpose of increased redundancy and just
1000 wastes filesystem space without providing the expected level of redundancy.
1001 .sp
1002 The duplicated data/metadata may still be useful to statistically improve the
1003 chances on a device that might perform some internal optimizations. The actual
1004 details are not usually disclosed by vendors. For example we could expect that
1005 not all blocks get deduplicated. This will provide a non\-zero probability of
1006 recovery compared to a zero chance if the single profile is used. The user
1007 should make the tradeoff decision. The deduplication in SSDs is thought to be
1008 widely available so the reason behind the mkfs default is to not give a false
1009 sense of redundancy.
1010 .sp
1011 As another example, the widely used USB flash or SD cards use a translation
1012 layer between the logical and physical view of the device. The data lifetime
1013 may be affected by frequent plugging. The memory cells could get damaged,
1014 hopefully not destroying both copies of particular data in case of DUP.
1015 .sp
1016 The wear levelling techniques can also lead to reduced redundancy, even if the
1017 device does not do any deduplication. The controllers may put data written in
1018 a short time span into the same physical storage unit (cell, block etc). In case
1019 this unit dies, both copies are lost. BTRFS does not add any artificial delay
1020 between metadata writes.
1021 .sp
1022 The traditional rotational hard drives usually fail at the sector level.
1023 .sp
1024 In any case, a device that starts to misbehave and repairs from the DUP copy
1025 should be replaced! \fBDUP is not backup\fP\&.
1026 .SH KNOWN ISSUES
1027 .sp
1028 \fBSMALL FILESYSTEMS AND LARGE NODESIZE\fP
1029 .sp
1030 The combination of small filesystem size and large nodesize is not recommended
1031 in general and can lead to various ENOSPC\-related issues during mount time or runtime.
1032 .sp
1033 Since mixed block group creation is optional, we allow small
1034 filesystem instances with differing values for \fIsectorsize\fP and \fInodesize\fP
1035 to be created and could end up in the following situation:
1036 .INDENT 0.0
1037 .INDENT 3.5
1038 .sp
1039 .EX
1040 # mkfs.btrfs \-f \-n 65536 /dev/loop0
1041 btrfs\-progs v3.19\-rc2\-405\-g976307c
1042 See https://btrfs.readthedocs.io for more information.
1043
1044 Performing full device TRIM (512.00MiB) ...
1045 Label: (null)
1046 UUID: 49fab72e\-0c8b\-466b\-a3ca\-d1bfe56475f0
1047 Node size: 65536
1048 Sector size: 4096
1049 Filesystem size: 512.00MiB
1050 Block group profiles:
1051 Data: single 8.00MiB
1052 Metadata: DUP 40.00MiB
1053 System: DUP 12.00MiB
1054 SSD detected: no
1055 Incompat features: extref, skinny\-metadata
1056 Number of devices: 1
1057 Devices:
1058 ID SIZE PATH
1059 1 512.00MiB /dev/loop0
1060
1061 # mount /dev/loop0 /mnt/
1062 mount: mount /dev/loop0 on /mnt failed: No space left on device
1063 .EE
1064 .UNINDENT
1065 .UNINDENT
1066 .sp
1067 The ENOSPC occurs during the creation of the UUID tree. This is caused
1068 by large metadata blocks and space reservation strategy that allocates more
1069 than can fit into the filesystem.
1070 .SH AVAILABILITY
1071 .sp
1072 \fBbtrfs\fP is part of btrfs\-progs. Please refer to the documentation at
1073 \X'tty: link https://btrfs.readthedocs.io'\fI\%https://btrfs.readthedocs.io\fP\X'tty: link'\&.
1074 .SH SEE ALSO
1075 .sp
1076 \fI\%btrfs(5)\fP,
1077 \fI\%btrfs(8)\fP,
1078 \fI\%btrfs\-balance(8)\fP,
1079 \X'tty: link https://man7.org/linux/man-pages/man8/wipefs.8.html'\fI\%wipefs(8)\fP\X'tty: link'
1080 .\" Generated by docutils manpage writer.
1081 .