1mkfs.xfs(8) System Manager's Manual mkfs.xfs(8)
2
3
4
6 mkfs.xfs - construct an XFS filesystem
7
9 mkfs.xfs [ -b block_size ] [ -m global_metadata_options ] [ -d
10 data_section_options ] [ -f ] [ -i inode_options ] [ -l log_sec‐
11 tion_options ] [ -n naming_options ] [ -p protofile ] [ -q ] [ -r real‐
12 time_section_options ] [ -s sector_size ] [ -L label ] [ -N ] [ -K ]
13 device
14 mkfs.xfs -V
15
17 mkfs.xfs constructs an XFS filesystem by writing on a special file
18 using the values found in the arguments of the command line. It is
19 invoked automatically by mkfs(8) when it is given the -t xfs option.
20
21 In its simplest (and most commonly used form), the size of the filesys‐
22 tem is determined from the disk driver. As an example, to make a
23 filesystem with an internal log on the first partition on the first
24 SCSI disk, use:
25
26 mkfs.xfs /dev/sda1
27
28 The metadata log can be placed on another device to reduce the number
29 of disk seeks. To create a filesystem on the first partition on the
30 first SCSI disk with a 10000 block log located on the first partition
31 on the second SCSI disk, use:
32
33 mkfs.xfs -l logdev=/dev/sdb1,size=10000b /dev/sda1
34
35 Each of the option elements in the argument list above can be given as
36 multiple comma-separated suboptions if multiple suboptions apply to the
37 same option. Equivalently, each main option can be given multiple
38 times with different suboptions. For example, -l internal,size=10000b
39 and -l internal -l size=10000b are equivalent.
40
41 In the descriptions below, sizes are given in sectors, bytes, blocks,
42 kilobytes, megabytes, gigabytes, etc. Sizes are treated as hexadecimal
43 if prefixed by 0x or 0X, octal if prefixed by 0, or decimal otherwise.
44 The following lists possible multiplication suffixes:
45 s - multiply by sector size (default = 512, see -s option
46 below).
47 b - multiply by filesystem block size (default = 4K, see -b
48 option below).
49 k - multiply by one kilobyte (1,024 bytes).
50 m - multiply by one megabyte (1,048,576 bytes).
51 g - multiply by one gigabyte (1,073,741,824 bytes).
52 t - multiply by one terabyte (1,099,511,627,776 bytes).
53 p - multiply by one petabyte (1,024 terabytes).
54 e - multiply by one exabyte (1,048,576 terabytes).
55
57 -b block_size_options
58 This option specifies the fundamental block size of the filesys‐
59 tem. The valid block_size_options are: log=value or size=value
60 and only one can be supplied. The block size is specified
61 either as a base two logarithm value with log=, or in bytes with
62 size=. The default value is 4096 bytes (4 KiB), the minimum is
63 512, and the maximum is 65536 (64 KiB). Although mkfs.xfs will
64 accept any of these values and create a valid filesystem, XFS on
65 Linux can only mount filesystems with pagesize or smaller
66 blocks.
67
68 -m global_metadata_options
69 These options specify metadata format options that either apply
70 to the entire filesystem or aren't easily characterised by a
71 specific functionality group. The valid global_metadata_options
72 are:
73
74 crc=value
75 This is used to create a filesystem which maintains
76 and checks CRC information in all metadata objects
77 on disk. The value is either 0 to disable the fea‐
78 ture, or 1 to enable the use of CRCs.
79
80 CRCs enable enhanced error detection due to hardware
81 issues, whilst the format changes also improves
82 crash recovery algorithms and the ability of various
83 tools to validate and repair metadata corruptions
84 when they are found. The CRC algorithm used is
85 CRC32c, so the overhead is dependent on CPU archi‐
86 tecture as some CPUs have hardware acceleration of
87 this algorithm. Typically the overhead of calculat‐
88 ing and checking the CRCs is not noticeable in nor‐
89 mal operation.
90
91 By default, mkfs.xfs will enable metadata CRCs.
92
93 finobt=value
94 This option enables the use of a separate free inode
95 btree index in each allocation group. The value is
96 either 0 to disable the feature, or 1 to create a
97 free inode btree in each allocation group.
98
99 The free inode btree mirrors the existing allocated
100 inode btree index which indexes both used and free
101 inodes. The free inode btree does not index used
102 inodes, allowing faster, more consistent inode allo‐
103 cation performance as filesystems age.
104
105 By default, mkfs.xfs will not create free inode
106 btrees for filesystems. This is for backwards com‐
107 patibility with older RHEL7 kernels. If the free
108 inode btree is enabled, older RHEL7 kernels will not
109 be able to mount the created filesystem. When the
110 option -m crc=0 is used, the free inode btree fea‐
111 ture is not supported and is disabled.
112
113 uuid=value
114 Use the given value as the filesystem UUID for the
115 newly created filesystem. The default is to gener‐
116 ate a random UUID.
117
118 -d data_section_options
119 These options specify the location, size, and other parameters
120 of the data section of the filesystem. The valid data_sec‐
121 tion_options are:
122
123 agcount=value
124 This is used to specify the number of allocation
125 groups. The data section of the filesystem is
126 divided into allocation groups to improve the per‐
127 formance of XFS. More allocation groups imply that
128 more parallelism can be achieved when allocating
129 blocks and inodes. The minimum allocation group size
130 is 16 MiB; the maximum size is just under 1 TiB.
131 The data section of the filesystem is divided into
132 value allocation groups (default value is scaled
133 automatically based on the underlying device size).
134
135 agsize=value
136 This is an alternative to using the agcount subop‐
137 tion. The value is the desired size of the alloca‐
138 tion group expressed in bytes (usually using the m
139 or g suffixes). This value must be a multiple of
140 the filesystem block size, and must be at least
141 16MiB, and no more than 1TiB, and may be automati‐
142 cally adjusted to properly align with the stripe
143 geometry. The agcount and agsize suboptions are
144 mutually exclusive.
145
146 name=value
147 This can be used to specify the name of the special
148 file containing the filesystem. In this case, the
149 log section must be specified as internal (with a
150 size, see the -l option below) and there can be no
151 real-time section.
152
153 file[=value]
154 This is used to specify that the file given by the
155 name suboption is a regular file. The value is
156 either 0 or 1, with 1 signifying that the file is
157 regular. This suboption is used only to make a
158 filesystem image. If the value is omitted then 1 is
159 assumed.
160
161 size=value
162 This is used to specify the size of the data sec‐
163 tion. This suboption is required if -d file[=1] is
164 given. Otherwise, it is only needed if the filesys‐
165 tem should occupy less space than the size of the
166 special file.
167
168 sunit=value
169 This is used to specify the stripe unit for a RAID
170 device or a logical volume. The value has to be
171 specified in 512-byte block units. Use the su subop‐
172 tion to specify the stripe unit size in bytes. This
173 suboption ensures that data allocations will be
174 stripe unit aligned when the current end of file is
175 being extended and the file size is larger than
176 512KiB. Also inode allocations and the internal log
177 will be stripe unit aligned.
178
179 su=value
180 This is an alternative to using sunit. The su sub‐
181 option is used to specify the stripe unit for a RAID
182 device or a striped logical volume. The value has to
183 be specified in bytes, (usually using the m or g
184 suffixes). This value must be a multiple of the
185 filesystem block size.
186
187 swidth=value
188 This is used to specify the stripe width for a RAID
189 device or a striped logical volume. The value has to
190 be specified in 512-byte block units. Use the sw
191 suboption to specify the stripe width size in bytes.
192 This suboption is required if -d sunit has been
193 specified and it has to be a multiple of the -d
194 sunit suboption.
195
196 sw=value
197 suboption is an alternative to using swidth. The sw
198 suboption is used to specify the stripe width for a
199 RAID device or striped logical volume. The value is
200 expressed as a multiplier of the stripe unit, usu‐
201 ally the same as the number of stripe members in the
202 logical volume configuration, or data disks in a
203 RAID device.
204
205 When a filesystem is created on a logical volume
206 device, mkfs.xfs will automatically query the logi‐
207 cal volume for appropriate sunit and swidth values.
208
209 noalign
210 This option disables automatic geometry detection
211 and creates the filesystem without stripe geometry
212 alignment even if the underlying storage device pro‐
213 vides this information.
214
215 -f Force overwrite when an existing filesystem is detected on the
216 device. By default, mkfs.xfs will not write to the device if it
217 suspects that there is a filesystem or partition table on the
218 device already.
219
220 -i inode_options
221 This option specifies the inode size of the filesystem, and
222 other inode allocation parameters. The XFS inode contains a
223 fixed-size part and a variable-size part. The variable-size
224 part, whose size is affected by this option, can contain: direc‐
225 tory data, for small directories; attribute data, for small
226 attribute sets; symbolic link data, for small symbolic links;
227 the extent list for the file, for files with a small number of
228 extents; and the root of a tree describing the location of
229 extents for the file, for files with a large number of extents.
230
231 The valid inode_options are:
232
233 size=value | log=value | perblock=value
234 The inode size is specified either as a value in
235 bytes with size=, a base two logarithm value with
236 log=, or as the number fitting in a filesystem block
237 with perblock=. The minimum (and default) value is
238 256 bytes. The maximum value is 2048 (2 KiB) sub‐
239 ject to the restriction that the inode size cannot
240 exceed one half of the filesystem block size.
241
242 XFS uses 64-bit inode numbers internally; however,
243 the number of significant bits in an inode number is
244 affected by filesystem geometry. In practice,
245 filesystem size and inode size are the predominant
246 factors. The Linux kernel (on 32 bit hardware plat‐
247 forms) and most applications cannot currently handle
248 inode numbers greater than 32 significant bits, so
249 if no inode size is given on the command line,
250 mkfs.xfs will attempt to choose a size such that
251 inode numbers will be < 32 bits. If an inode size
252 is specified, or if a filesystem is sufficiently
253 large, mkfs.xfs will warn if this will create inode
254 numbers > 32 significant bits.
255
256 maxpct=value
257 This specifies the maximum percentage of space in
258 the filesystem that can be allocated to inodes. The
259 default value is 25% for filesystems under 1TB, 5%
260 for filesystems under 50TB and 1% for filesystems
261 over 50TB.
262
263 In the default inode allocation mode, inode blocks
264 are chosen such that inode numbers will not exceed
265 32 bits, which restricts the inode blocks to the
266 lower portion of the filesystem. The data block
267 allocator will avoid these low blocks to accommodate
268 the specified maxpct, so a high value may result in
269 a filesystem with nothing but inodes in a signifi‐
270 cant portion of the lower blocks of the filesystem.
271 (This restriction is not present when the filesystem
272 is mounted with the inode64 option on 64-bit plat‐
273 forms).
274
275 Setting the value to 0 means that essentially all of
276 the filesystem can become inode blocks, subject to
277 inode32 restrictions.
278
279 This value can be modified with xfs_growfs(8).
280
281 align[=value]
282 This is used to specify that inode allocation is or
283 is not aligned. The value is either 0 or 1, with 1
284 signifying that inodes are allocated aligned. If
285 the value is omitted, 1 is assumed. The default is
286 that inodes are aligned. Aligned inode access is
287 normally more efficient than unaligned access;
288 alignment must be established at the time the
289 filesystem is created, since inodes are allocated at
290 that time. This option can be used to turn off
291 inode alignment when the filesystem needs to be
292 mountable by a version of IRIX that does not have
293 the inode alignment feature (any release of IRIX
294 before 6.2, and IRIX 6.2 without XFS patches).
295
296 attr=value
297 This is used to specify the version of extended
298 attribute inline allocation policy to be used. By
299 default, this is 2, which uses an efficient algo‐
300 rithm for managing the available inline inode space
301 between attribute and extent data.
302
303 The previous version 1, which has fixed regions for
304 attribute and extent data, is kept for backwards
305 compatibility with kernels older than version
306 2.6.16.
307
308 projid32bit[=value]
309 This is used to enable 32bit quota project identi‐
310 fiers. The value is either 0 or 1, with 1 signifying
311 that 32bit projid are to be enabled. If the value
312 is omitted, 1 is assumed. (This default changed in
313 release version 3.2.0.)
314
315 sparse[=value]
316 Enable sparse inode chunk allocation. This experi‐
317 mental option is not available in RHEL7.
318
319 -l log_section_options
320 These options specify the location, size, and other parameters
321 of the log section of the filesystem. The valid log_sec‐
322 tion_options are:
323
324 internal[=value]
325 This is used to specify that the log section is a
326 piece of the data section instead of being another
327 device or logical volume. The value is either 0 or
328 1, with 1 signifying that the log is internal. If
329 the value is omitted, 1 is assumed.
330
331 logdev=device
332 This is used to specify that the log section should
333 reside on the device separate from the data section.
334 The internal=1 and logdev options are mutually
335 exclusive.
336
337 size=value
338 This is used to specify the size of the log section.
339
340 If the log is contained within the data section and
341 size isn't specified, mkfs.xfs will try to select a
342 suitable log size depending on the size of the
343 filesystem. The actual logsize depends on the
344 filesystem block size and the directory block size.
345
346 Otherwise, the size suboption is only needed if the
347 log section of the filesystem should occupy less
348 space than the size of the special file. The value
349 is specified in bytes or blocks, with a b suffix
350 meaning multiplication by the filesystem block size,
351 as described above. The overriding minimum value for
352 size is 512 blocks. With some combinations of
353 filesystem block size, inode size, and directory
354 block size, the minimum log size is larger than 512
355 blocks.
356
357 version=value
358 This specifies the version of the log. The current
359 default is 2, which allows for larger log buffer
360 sizes, as well as supporting stripe-aligned log
361 writes (see the sunit and su options, below).
362
363 The previous version 1, which is limited to 32k log
364 buffers and does not support stripe-aligned writes,
365 is kept for backwards compatibility with very old
366 2.4 kernels.
367
368 sunit=value
369 This specifies the alignment to be used for log
370 writes. The value has to be specified in 512-byte
371 block units. Use the su suboption to specify the log
372 stripe unit size in bytes. Log writes will be
373 aligned on this boundary, and rounded up to this
374 boundary. This gives major improvements in perfor‐
375 mance on some configurations such as software RAID5
376 when the sunit is specified as the filesystem block
377 size. The equivalent byte value must be a multiple
378 of the filesystem block size. Version 2 logs are
379 automatically selected if the log sunit suboption is
380 specified.
381
382 The su suboption is an alternative to using sunit.
383
384 su=value
385 This is used to specify the log stripe. The value
386 has to be specified in bytes, (usually using the s
387 or b suffixes). This value must be a multiple of the
388 filesystem block size. Version 2 logs are automati‐
389 cally selected if the log su suboption is specified.
390
391 lazy-count=value
392 This changes the method of logging various persis‐
393 tent counters in the superblock. Under metadata
394 intensive workloads, these counters are updated and
395 logged frequently enough that the superblock updates
396 become a serialization point in the filesystem. The
397 value can be either 0 or 1.
398
399 With lazy-count=1, the superblock is not modified or
400 logged on every change of the persistent counters.
401 Instead, enough information is kept in other parts
402 of the filesystem to be able to maintain the persis‐
403 tent counter values without needed to keep them in
404 the superblock. This gives significant improvements
405 in performance on some configurations. The default
406 value is 1 (on) so you must specify lazy-count=0 if
407 you want to disable this feature for older kernels
408 which don't support it.
409
410 -n naming_options
411 These options specify the version and size parameters for the
412 naming (directory) area of the filesystem. The valid nam‐
413 ing_options are:
414
415 size=value | log=value
416 The block size is specified either as a value in
417 bytes with size=, or as a base two logarithm value
418 with log=. The block size must be a power of 2 and
419 cannot be less than the filesystem block size. The
420 default size value for version 2 directories is 4096
421 bytes (4 KiB), unless the filesystem block size is
422 larger than 4096, in which case the default value is
423 the filesystem block size. For version 1 directo‐
424 ries the block size is the same as the filesystem
425 block size.
426
427 version=value
428 The naming (directory) version value can be either 2
429 or 'ci', defaulting to 2 if unspecified. With ver‐
430 sion 2 directories, the directory block size can be
431 any power of 2 size from the filesystem block size
432 up to 65536.
433
434 The version=ci option enables ASCII only case-insen‐
435 sitive filename lookup and version 2 directories.
436 Filenames are case-preserving, that is, the names
437 are stored in directories using the case they were
438 created with.
439
440 Note: Version 1 directories are not supported.
441
442 ftype=value
443 This feature allows the inode type to be stored in
444 the directory structure so that the readdir(3) and
445 getdents(2) do not need to look up the inode to
446 determine the inode type.
447
448 The value is either 0 or 1, with 1 signifying that
449 filetype information will be stored in the directory
450 structure. The default value is 1.
451
452 When CRCs are enabled (the default), the ftype func‐
453 tionality is always enabled, and cannot be turned
454 off.
455
456 -p protofile
457 If the optional -p protofile argument is given, mkfs.xfs uses
458 protofile as a prototype file and takes its directions from that
459 file. The blocks and inodes specifiers in the protofile are
460 provided for backwards compatibility, but are otherwise unused.
461 The syntax of the protofile is defined by a number of tokens
462 separated by spaces or newlines. Note that the line numbers are
463 not part of the syntax but are meant to help you in the follow‐
464 ing discussion of the file contents.
465
466 1 /stand/diskboot
467 2 4872 110
468 3 d--777 3 1
469 4 usr d--777 3 1
470 5 sh ---755 3 1 /bin/sh
471 6 ken d--755 6 1
472 7 $
473 8 b0 b--644 3 1 0 0
474 9 c0 c--644 3 1 0 0
475 10 fifo p--644 3 1
476 11 slink l--644 3 1 /a/symbolic/link
477 12 : This is a comment line
478 13 $
479 14 $
480
481 Line 1 is a dummy string. (It was formerly the bootfilename.)
482 It is present for backward compatibility; boot blocks are not
483 used on SGI systems.
484
485 Note that some string of characters must be present as the first
486 line of the proto file to cause it to be parsed correctly; the
487 value of this string is immaterial since it is ignored.
488
489 Line 2 contains two numeric values (formerly the numbers of
490 blocks and inodes). These are also merely for backward compati‐
491 bility: two numeric values must appear at this point for the
492 proto file to be correctly parsed, but their values are immate‐
493 rial since they are ignored.
494
495 The lines 3 through 11 specify the files and directories you
496 want to include in this filesystem. Line 3 defines the root
497 directory. Other directories and files that you want in the
498 filesystem are indicated by lines 4 through 6 and lines 8
499 through 10. Line 11 contains symbolic link syntax.
500
501 Notice the dollar sign ($) syntax on line 7. This syntax directs
502 the mkfs.xfs command to terminate the branch of the filesystem
503 it is currently on and then continue from the directory speci‐
504 fied by the next line, in this case line 8. It must be the last
505 character on a line. The colon on line 12 introduces a comment;
506 all characters up until the following newline are ignored. Note
507 that this means you cannot have a file in a prototype file whose
508 name contains a colon. The $ on lines 13 and 14 end the
509 process, since no additional specifications follow.
510
511 File specifications provide the following:
512
513 * file mode
514 * user ID
515 * group ID
516 * the file's beginning contents
517
518 A 6-character string defines the mode for a file. The first
519 character of this string defines the file type. The character
520 range for this first character is -bcdpl. A file may be a regu‐
521 lar file, a block special file, a character special file, direc‐
522 tory files, named pipes (first-in, first out files), and sym‐
523 bolic links. The second character of the mode string is used to
524 specify setuserID mode, in which case it is u. If setuserID
525 mode is not specified, the second character is -. The third
526 character of the mode string is used to specify the setgroupID
527 mode, in which case it is g. If setgroupID mode is not speci‐
528 fied, the third character is -. The remaining characters of the
529 mode string are a three digit octal number. This octal number
530 defines the owner, group, and other read, write, and execute
531 permissions for the file, respectively. For more information on
532 file permissions, see the chmod(1) command.
533
534 Following the mode character string are two decimal number
535 tokens that specify the user and group IDs of the file's owner.
536
537 In a regular file, the next token specifies the pathname from
538 which the contents and size of the file are copied. In a block
539 or character special file, the next token are two decimal num‐
540 bers that specify the major and minor device numbers. When a
541 file is a symbolic link, the next token specifies the contents
542 of the link.
543
544 When the file is a directory, the mkfs.xfs command creates the
545 entries dot (.) and dot-dot (..) and then reads the list of
546 names and file specifications in a recursive manner for all of
547 the entries in the directory. A scan of the protofile is always
548 terminated with the dollar ( $ ) token.
549
550 -q Quiet option. Normally mkfs.xfs prints the parameters of the
551 filesystem to be constructed; the -q flag suppresses this.
552
553 -r realtime_section_options
554 These options specify the location, size, and other parameters
555 of the real-time section of the filesystem. The valid real‐
556 time_section_options are:
557
558 rtdev=device
559 This is used to specify the device which should con‐
560 tain the real-time section of the filesystem. The
561 suboption value is the name of a block device.
562
563 extsize=value
564 This is used to specify the size of the blocks in
565 the real-time section of the filesystem. This value
566 must be a multiple of the filesystem block size. The
567 minimum allowed size is the filesystem block size or
568 4 KiB (whichever is larger); the default size is the
569 stripe width for striped volumes or 64 KiB for non-
570 striped volumes; the maximum allowed size is 1 GiB.
571 The real-time extent size should be carefully chosen
572 to match the parameters of the physical media used.
573
574 size=value
575 This is used to specify the size of the real-time
576 section. This suboption is only needed if the real-
577 time section of the filesystem should occupy less
578 space than the size of the partition or logical vol‐
579 ume containing the section.
580
581 noalign
582 This option disables stripe size detection, enforc‐
583 ing a realtime device with no stripe geometry.
584
585 -s sector_size
586 This option specifies the fundamental sector size of the
587 filesystem. The sector_size is specified either as a value in
588 bytes with size=value or as a base two logarithm value with
589 log=value. The default sector_size is 512 bytes. The minimum
590 value for sector size is 512; the maximum is 32768 (32 KiB). The
591 sector_size must be a power of 2 size and cannot be made larger
592 than the filesystem block size.
593
594 -L label
595 Set the filesystem label. XFS filesystem labels can be at most
596 12 characters long; if label is longer than 12 characters,
597 mkfs.xfs will not proceed with creating the filesystem. Refer
598 to the mount(8) and xfs_admin(8) manual entries for additional
599 information.
600
601 -N Causes the file system parameters to be printed out without
602 really creating the file system.
603
604 -K Do not attempt to discard blocks at mkfs time.
605
606 -V Prints the version number and exits.
607
609 xfs(5), mkfs(8), mount(8), xfs_info(8), xfs_admin(8).
610
612 With a prototype file, it is not possible to specify hard links.
613
614
615
616 mkfs.xfs(8)