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

Performing full device TRIM (512.00MiB) ...
Label:              (null)
UUID:               49fab72e\-0c8b\-466b\-a3ca\-d1bfe56475f0
Node size:          65536
Sector size:        4096
Filesystem size:    512.00MiB
Block group profiles:
  Data:             single            8.00MiB
  Metadata:         DUP              40.00MiB
  System:           DUP              12.00MiB
SSD detected:       no
Incompat features:  extref, skinny\-metadata
Number of devices:  1
Devices:
  ID        SIZE  PATH
   1   512.00MiB  /dev/loop0

# mount /dev/loop0 /mnt/
mount: mount /dev/loop0 on /mnt failed: No space left on device
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
The ENOSPC occurs during the creation of the UUID tree. This is caused
by large metadata blocks and space reservation strategy that allocates more
than can fit into the filesystem.
.SH AVAILABILITY
.sp
\fBbtrfs\fP is part of btrfs\-progs.  Please refer to the documentation at
\fI\%https://btrfs.readthedocs.io\fP\&.
.SH SEE ALSO
.sp
\fI\%btrfs(5)\fP,
\fI\%btrfs(8)\fP,
\fI\%btrfs\-balance(8)\fP,
\fBwipefs(8)\fP
.\" Generated by docutils manpage writer.
.