1MKE2FS(8) System Manager's Manual MKE2FS(8)
2
3
4
6 mke2fs - create an ext2/ext3/ext4 file system
7
9 mke2fs [ -c | -l filename ] [ -b block-size ] [ -C cluster-size ] [ -d
10 root-directory ] [ -D ] [ -g blocks-per-group ] [ -G number-of-groups ]
11 [ -i bytes-per-inode ] [ -I inode-size ] [ -j ] [ -J journal-options ]
12 [ -N number-of-inodes ] [ -n ] [ -m reserved-blocks-percentage ] [ -o
13 creator-os ] [ -O [^]feature[,...] ] [ -q ] [ -r fs-revision-level ] [
14 -E extended-options ] [ -v ] [ -F ] [ -L volume-label ] [ -M last-
15 mounted-directory ] [ -S ] [ -t fs-type ] [ -T usage-type ] [ -U UUID ]
16 [ -V ] [ -e errors-behavior ] [ -z undo_file ] device [ fs-size ]
17
18 mke2fs -O journal_dev [ -b block-size ] [ -L volume-label ] [ -n ] [ -q
19 ] [ -v ] external-journal [ fs-size ]
20
22 mke2fs is used to create an ext2, ext3, or ext4 file system, usually in
23 a disk partition (or file) named by device.
24
25 The file system size is specified by fs-size. If fs-size does not have
26 a suffix, it is interpreted as power-of-two kilobytes, unless the -b
27 blocksize option is specified, in which case fs-size is interpreted as
28 the number of blocksize blocks. If the fs-size is suffixed by 'k',
29 'm', 'g', 't' (either upper-case or lower-case), then it is interpreted
30 in power-of-two kilobytes, megabytes, gigabytes, terabytes, etc. If
31 fs-size is omitted, mke2fs will create the file system based on the de‐
32 vice size.
33
34 If mke2fs is run as mkfs.XXX (i.e., mkfs.ext2, mkfs.ext3, or mkfs.ext4)
35 the option -t XXX is implied; so mkfs.ext3 will create a file system
36 for use with ext3, mkfs.ext4 will create a file system for use with
37 ext4, and so on.
38
39 The defaults of the parameters for the newly created file system, if
40 not overridden by the options listed below, are controlled by the
41 /etc/mke2fs.conf configuration file. See the mke2fs.conf(5) manual
42 page for more details.
43
45 -b block-size
46 Specify the size of blocks in bytes. Valid block-size values
47 are powers of two from 1024 up to 65536 (however note that the
48 kernel is able to mount only file systems with block-size
49 smaller or equal to the system page size - 4k on x86 systems, up
50 to 64k on ppc64 or aarch64 depending on kernel configuration).
51 If omitted, block-size is heuristically determined by the file
52 system size and the expected usage of the file system (see the
53 -T option). In most common cases, the default block size is 4k.
54 If block-size is preceded by a negative sign ('-'), then mke2fs
55 will use heuristics to determine the appropriate block size,
56 with the constraint that the block size will be at least block-
57 size bytes. This is useful for certain hardware devices which
58 require that the blocksize be a multiple of 2k.
59
60 -c Check the device for bad blocks before creating the file system.
61 If this option is specified twice, then a slower read-write test
62 is used instead of a fast read-only test.
63
64 -C cluster-size
65 Specify the size of cluster in bytes for file systems using the
66 bigalloc feature. Valid cluster-size values are from 2048 to
67 256M bytes per cluster. This can only be specified if the bi‐
68 galloc feature is enabled. (See the ext4 (5) man page for more
69 details about bigalloc.) The default cluster size if bigalloc
70 is enabled is 16 times the block size.
71
72 -d root-directory
73 Copy the contents of the given directory into the root directory
74 of the file system.
75
76 -D Use direct I/O when writing to the disk. This avoids mke2fs
77 dirtying a lot of buffer cache memory, which may impact other
78 applications running on a busy server. This option will cause
79 mke2fs to run much more slowly, however, so there is a tradeoff
80 to using direct I/O.
81
82 -e error-behavior
83 Change the behavior of the kernel code when errors are detected.
84 In all cases, a file system error will cause e2fsck(8) to check
85 the file system on the next boot. error-behavior can be one of
86 the following:
87
88 continue Continue normal execution.
89
90 remount-ro Remount file system read-only.
91
92 panic Cause a kernel panic.
93
94 -E extended-options
95 Set extended options for the file system. Extended options are
96 comma separated, and may take an argument using the equals ('=')
97 sign. The -E option used to be -R in earlier versions of
98 mke2fs. The -R option is still accepted for backwards compati‐
99 bility, but is deprecated. The following extended options are
100 supported:
101
102 encoding=encoding-name
103 Enable the casefold feature in the super block and
104 set encoding-name as the encoding to be used. If
105 encoding-name is not specified, the encoding defined
106 in mke2fs.conf(5) is used.
107
108 encoding_flags=encoding-flags
109 Define parameters for file name character encoding
110 operations. If a flag is not changed using this pa‐
111 rameter, its default value is used. encoding-flags
112 should be a comma-separated lists of flags to be en‐
113 abled. To disable a flag, add it to the list with
114 the prefix "no".
115
116 The only flag that can be set right now is strict
117 which means that invalid strings should be rejected
118 by the file system. In the default configuration,
119 the strict flag is disabled.
120
121 mmp_update_interval=interval
122 Adjust the initial MMP update interval to interval
123 seconds. Specifying an interval of 0 means to use
124 the default interval. The specified interval must
125 be less than 300 seconds. Requires that the mmp
126 feature be enabled.
127
128 stride=stride-size
129 Configure the file system for a RAID array with
130 stride-size file system blocks. This is the number
131 of blocks read or written to disk before moving to
132 the next disk, which is sometimes referred to as the
133 chunk size. This mostly affects placement of file
134 system metadata like bitmaps at mke2fs time to avoid
135 placing them on a single disk, which can hurt per‐
136 formance. It may also be used by the block alloca‐
137 tor.
138
139 stripe_width=stripe-width
140 Configure the file system for a RAID array with
141 stripe-width file system blocks per stripe. This is
142 typically stride-size * N, where N is the number of
143 data-bearing disks in the RAID (e.g. for RAID 5
144 there is one parity disk, so N will be the number of
145 disks in the array minus 1). This allows the block
146 allocator to prevent read-modify-write of the parity
147 in a RAID stripe if possible when the data is writ‐
148 ten.
149
150 offset=offset
151 Create the file system at an offset from the begin‐
152 ning of the device or file. This can be useful when
153 creating disk images for virtual machines.
154
155 resize=max-online-resize
156 Reserve enough space so that the block group de‐
157 scriptor table can grow to support a file system
158 that has max-online-resize blocks.
159
160 lazy_itable_init[= <0 to disable, 1 to enable>]
161 If enabled and the uninit_bg feature is enabled, the
162 inode table will not be fully initialized by mke2fs.
163 This speeds up file system initialization notice‐
164 ably, but it requires the kernel to finish initial‐
165 izing the file system in the background when the
166 file system is first mounted. If the option value
167 is omitted, it defaults to 1 to enable lazy inode
168 table zeroing.
169
170 lazy_journal_init[= <0 to disable, 1 to enable>]
171 If enabled, the journal inode will not be fully ze‐
172 roed out by mke2fs. This speeds up file system ini‐
173 tialization noticeably, but carries some small risk
174 if the system crashes before the journal has been
175 overwritten entirely one time. If the option value
176 is omitted, it defaults to 1 to enable lazy journal
177 inode zeroing.
178
179 assume_storage_prezeroed[= <0 to disable, 1 to enable>]
180 If enabled, mke2fs assumes that the storage device
181 has been prezeroed, skips zeroing the journal and
182 inode tables, and annotates the block group flags to
183 signal that the inode table has been zeroed.
184
185 no_copy_xattrs
186 Normally mke2fs will copy the extended attributes of
187 the files in the directory hierarchy specified via
188 the (optional) -d option. This will disable the
189 copy and leaves the files in the newly created file
190 system without any extended attributes.
191
192 num_backup_sb=<0|1|2>
193 If the sparse_super2 file system feature is enabled
194 this option controls whether there will be 0, 1, or
195 2 backup superblocks created in the file system.
196
197 packed_meta_blocks[= <0 to disable, 1 to enable>]
198 Place the allocation bitmaps and the inode table at
199 the beginning of the disk. This option requires
200 that the flex_bg file system feature to be enabled
201 in order for it to have effect, and will also create
202 the journal at the beginning of the file system.
203 This option is useful for flash devices that use SLC
204 flash at the beginning of the disk. It also maxi‐
205 mizes the range of contiguous data blocks, which can
206 be useful for certain specialized use cases, such as
207 supported Shingled Drives.
208
209 root_owner[=uid:gid]
210 Specify the numeric user and group ID of the root
211 directory. If no UID:GID is specified, use the user
212 and group ID of the user running mke2fs. In mke2fs
213 1.42 and earlier the UID and GID of the root direc‐
214 tory were set by default to the UID and GID of the
215 user running the mke2fs command. The root_owner=
216 option allows explicitly specifying these values,
217 and avoid side-effects for users that do not expect
218 the contents of the file system to change based on
219 the user running mke2fs.
220
221 test_fs
222 Set a flag in the file system superblock indicating
223 that it may be mounted using experimental kernel
224 code, such as the ext4dev file system.
225
226 orphan_file_size=size
227 Set size of the file for tracking unlinked but still
228 open inodes and inodes with truncate in progress.
229 Larger file allows for better scalability, reserving
230 a few blocks per cpu is ideal.
231
232 discard
233 Attempt to discard blocks at mkfs time (discarding
234 blocks initially is useful on solid state devices
235 and sparse / thin-provisioned storage). When the de‐
236 vice advertises that discard also zeroes data (any
237 subsequent read after the discard and before write
238 returns zero), then mark all not-yet-zeroed inode
239 tables as zeroed. This significantly speeds up file
240 system initialization. This is set as default.
241
242 nodiscard
243 Do not attempt to discard blocks at mkfs time.
244
245 quotatype
246 Specify the which quota types (usrquota, grpquota,
247 prjquota) which should be enabled in the created
248 file system. The argument of this extended option
249 should be a colon separated list. This option has
250 effect only if the quota feature is set. The de‐
251 fault quota types to be initialized if this option
252 is not specified is both user and group quotas. If
253 the project feature is enabled that project quotas
254 will be initialized as well.
255
256 -F Force mke2fs to create a file system, even if the specified de‐
257 vice is not a partition on a block special device, or if other
258 parameters do not make sense. In order to force mke2fs to cre‐
259 ate a file system even if the file system appears to be in use
260 or is mounted (a truly dangerous thing to do), this option must
261 be specified twice.
262
263 -g blocks-per-group
264 Specify the number of blocks in a block group. There is gener‐
265 ally no reason for the user to ever set this parameter, as the
266 default is optimal for the file system. (For administrators who
267 are creating file systems on RAID arrays, it is preferable to
268 use the stride RAID parameter as part of the -E option rather
269 than manipulating the number of blocks per group.) This option
270 is generally used by developers who are developing test cases.
271
272 If the bigalloc feature is enabled, the -g option will specify
273 the number of clusters in a block group.
274
275 -G number-of-groups
276 Specify the number of block groups that will be packed together
277 to create a larger virtual block group (or "flex_bg group") in
278 an ext4 file system. This improves meta-data locality and per‐
279 formance on meta-data heavy workloads. The number of groups
280 must be a power of 2 and may only be specified if the flex_bg
281 file system feature is enabled.
282
283 -i bytes-per-inode
284 Specify the bytes/inode ratio. mke2fs creates an inode for ev‐
285 ery bytes-per-inode bytes of space on the disk. The larger the
286 bytes-per-inode ratio, the fewer inodes will be created. This
287 value generally shouldn't be smaller than the blocksize of the
288 file system, since in that case more inodes would be made than
289 can ever be used. Be warned that it is not possible to change
290 this ratio on a file system after it is created, so be careful
291 deciding the correct value for this parameter. Note that resiz‐
292 ing a file system changes the number of inodes to maintain this
293 ratio.
294
295 -I inode-size
296 Specify the size of each inode in bytes. The inode-size value
297 must be a power of 2 larger or equal to 128. The larger the in‐
298 ode-size the more space the inode table will consume, and this
299 reduces the usable space in the file system and can also nega‐
300 tively impact performance. It is not possible to change this
301 value after the file system is created.
302
303 File systems with an inode size of 128 bytes do not support
304 timestamps beyond January 19, 2038. Inodes which are 256 bytes
305 or larger will support extended timestamps, project id's, and
306 the ability to store some extended attributes in the inode table
307 for improved performance.
308
309 The default inode size is controlled by the mke2fs.conf(5) file.
310 In the mke2fs.conf file shipped with e2fsprogs, the default in‐
311 ode size is 256 bytes for most file systems, except for small
312 file systems where the inode size will be 128 bytes.
313
314 -j Create the file system with an ext3 journal. If the -J option
315 is not specified, the default journal parameters will be used to
316 create an appropriately sized journal (given the size of the
317 file system) stored within the file system. Note that you must
318 be using a kernel which has ext3 support in order to actually
319 make use of the journal.
320
321 -J journal-options
322 Create the ext3 journal using options specified on the command-
323 line. Journal options are comma separated, and may take an ar‐
324 gument using the equals ('=') sign. The following journal op‐
325 tions are supported:
326
327 size=journal-size
328 Create an internal journal (i.e., stored inside the
329 file system) of size journal-size megabytes. The
330 size of the journal must be at least 1024 file sys‐
331 tem blocks (i.e., 1MB if using 1k blocks, 4MB if us‐
332 ing 4k blocks, etc.) and may be no more than
333 10,240,000 file system blocks or half the total file
334 system size (whichever is smaller)
335
336 fast_commit_size=fast-commit-size
337 Create an additional fast commit journal area of
338 size fast-commit-size kilobytes. This option is
339 only valid if fast_commit feature is enabled on the
340 file system. If this option is not specified and if
341 fast_commit feature is turned on, fast commit area
342 size defaults to journal-size / 64 megabytes. The
343 total size of the journal with fast_commit feature
344 set is journal-size + ( fast-commit-size * 1024)
345 megabytes. The total journal size may be no more
346 than 10,240,000 file system blocks or half the total
347 file system size (whichever is smaller).
348
349 location=journal-location
350 Specify the location of the journal. The argument
351 journal-location can either be specified as a block
352 number, or if the number has a units suffix (e.g.,
353 'M', 'G', etc.) interpret it as the offset from the
354 beginning of the file system.
355
356 device=external-journal
357 Attach the file system to the journal block device
358 located on external-journal. The external journal
359 must already have been created using the command
360
361 mke2fs -O journal_dev external-journal
362
363 Note that external-journal must have been created
364 with the same block size as the new file system. In
365 addition, while there is support for attaching mul‐
366 tiple file systems to a single external journal, the
367 Linux kernel and e2fsck(8) do not currently support
368 shared external journals yet.
369
370 Instead of specifying a device name directly, exter‐
371 nal-journal can also be specified by either LA‐
372 BEL=label or UUID=UUID to locate the external jour‐
373 nal by either the volume label or UUID stored in the
374 ext2 superblock at the start of the journal. Use
375 dumpe2fs(8) to display a journal device's volume la‐
376 bel and UUID. See also the -L option of tune2fs(8).
377
378 Only one of the size or device options can be given for a file
379 system.
380
381 -l filename
382 Read the bad blocks list from filename. Note that the block
383 numbers in the bad block list must be generated using the same
384 block size as used by mke2fs. As a result, the -c option to
385 mke2fs is a much simpler and less error-prone method of checking
386 a disk for bad blocks before formatting it, as mke2fs will auto‐
387 matically pass the correct parameters to the badblocks program.
388
389 -L new-volume-label
390 Set the volume label for the file system to new-volume-label.
391 The maximum length of the volume label is 16 bytes.
392
393 -m reserved-blocks-percentage
394 Specify the percentage of the file system blocks reserved for
395 the super-user. This avoids fragmentation, and allows root-
396 owned daemons, such as syslogd(8), to continue to function cor‐
397 rectly after non-privileged processes are prevented from writing
398 to the file system. The default percentage is 5%.
399
400 -M last-mounted-directory
401 Set the last mounted directory for the file system. This might
402 be useful for the sake of utilities that key off of the last
403 mounted directory to determine where the file system should be
404 mounted.
405
406 -n Causes mke2fs to not actually create a file system, but display
407 what it would do if it were to create a file system. This can
408 be used to determine the location of the backup superblocks for
409 a particular file system, so long as the mke2fs parameters that
410 were passed when the file system was originally created are used
411 again. (With the -n option added, of course!)
412
413 -N number-of-inodes
414 Overrides the default calculation of the number of inodes that
415 should be reserved for the file system (which is based on the
416 number of blocks and the bytes-per-inode ratio). This allows
417 the user to specify the number of desired inodes directly.
418
419 -o creator-os
420 Overrides the default value of the "creator operating system"
421 field of the file system. The creator field is set by default
422 to the name of the OS the mke2fs executable was compiled for.
423
424 -O [^]feature[,...]
425 Create a file system with the given features (file system op‐
426 tions), overriding the default file system options. The fea‐
427 tures that are enabled by default are specified by the base_fea‐
428 tures relation, either in the [defaults] section in the
429 /etc/mke2fs.conf configuration file, or in the [fs_types] sub‐
430 sections for the usage types as specified by the -T option, fur‐
431 ther modified by the features relation found in the [fs_types]
432 subsections for the file system and usage types. See the
433 mke2fs.conf(5) manual page for more details. The file system
434 type-specific configuration setting found in the [fs_types] sec‐
435 tion will override the global default found in [defaults].
436
437 The file system feature set will be further edited using either
438 the feature set specified by this option, or if this option is
439 not given, by the default_features relation for the file system
440 type being created, or in the [defaults] section of the configu‐
441 ration file.
442
443 The file system feature set is comprised of a list of features,
444 separated by commas, that are to be enabled. To disable a fea‐
445 ture, simply prefix the feature name with a caret ('^') charac‐
446 ter. Features with dependencies will not be removed success‐
447 fully. The pseudo-file system feature "none" will clear all
448 file system features.
449
450 For more information about the features which can be set, please see
451 the manual page ext4(5).
452
453 -q Quiet execution. Useful if mke2fs is run in a script.
454
455 -r revision
456 Set the file system revision for the new file system. Note that
457 1.2 kernels only support revision 0 file systems. The default
458 is to create revision 1 file systems.
459
460 -S Write superblock and group descriptors only. This is an extreme
461 measure to be taken only in the very unlikely case that all of
462 the superblock and backup superblocks are corrupted, and a last-
463 ditch recovery method is desired by experienced users. It
464 causes mke2fs to reinitialize the superblock and group descrip‐
465 tors, while not touching the inode table and the block and inode
466 bitmaps. The e2fsck program should be run immediately after
467 this option is used, and there is no guarantee that any data
468 will be salvageable. Due to the wide variety of possible op‐
469 tions to mke2fs that affect the on-disk layout, it is critical
470 to specify exactly the same format options, such as blocksize,
471 fs-type, feature flags, and other tunables when using this op‐
472 tion, or the file system will be further corrupted. In some
473 cases, such as file systems that have been resized, or have had
474 features enabled after format time, it is impossible to over‐
475 write all of the superblocks correctly, and at least some file
476 system corruption will occur. It is best to run this on a full
477 copy of the file system so other options can be tried if this
478 doesn't work.
479
480 -t fs-type
481 Specify the file system type (i.e., ext2, ext3, ext4, etc.) that
482 is to be created. If this option is not specified, mke2fs will
483 pick a default either via how the command was run (for example,
484 using a name of the form mkfs.ext2, mkfs.ext3, etc.) or via a
485 default as defined by the /etc/mke2fs.conf file. This option
486 controls which file system options are used by default, based on
487 the fstypes configuration stanza in /etc/mke2fs.conf.
488
489 If the -O option is used to explicitly add or remove file system
490 options that should be set in the newly created file system, the
491 resulting file system may not be supported by the requested fs-
492 type. (e.g., "mke2fs -t ext3 -O extent /dev/sdXX" will create a
493 file system that is not supported by the ext3 implementation as
494 found in the Linux kernel; and "mke2fs -t ext3 -O ^has_journal
495 /dev/hdXX" will create a file system that does not have a jour‐
496 nal and hence will not be supported by the ext3 file system code
497 in the Linux kernel.)
498
499 -T usage-type[,...]
500 Specify how the file system is going to be used, so that mke2fs
501 can choose optimal file system parameters for that use. The us‐
502 age types that are supported are defined in the configuration
503 file /etc/mke2fs.conf. The user may specify one or more usage
504 types using a comma separated list.
505
506 If this option is is not specified, mke2fs will pick a single
507 default usage type based on the size of the file system to be
508 created. If the file system size is less than 3 megabytes,
509 mke2fs will use the file system type floppy. If the file system
510 size is greater than or equal to 3 but less than 512 megabytes,
511 mke2fs(8) will use the file system type small. If the file sys‐
512 tem size is greater than or equal to 4 terabytes but less than
513 16 terabytes, mke2fs(8) will use the file system type big. If
514 the file system size is greater than or equal to 16 terabytes,
515 mke2fs(8) will use the file system type huge. Otherwise,
516 mke2fs(8) will use the default file system type default.
517
518 -U UUID
519 Set the universally unique identifier (UUID) of the file system
520 to UUID. The format of the UUID is a series of hex digits sepa‐
521 rated by hyphens, like this:
522 "c1b9d5a2-f162-11cf-9ece-0020afc76f16". The UUID parameter may
523 also be one of the following:
524
525 clear clear the file system UUID
526
527 random generate a new randomly-generated UUID
528
529 time generate a new time-based UUID
530
531 -v Verbose execution.
532
533 -V Print the version number of mke2fs and exit.
534
535 -z undo_file
536 Before overwriting a file system block, write the old contents
537 of the block to an undo file. This undo file can be used with
538 e2undo(8) to restore the old contents of the file system should
539 something go wrong. If the empty string is passed as the
540 undo_file argument, the undo file will be written to a file
541 named mke2fs-device.e2undo in the directory specified via the
542 E2FSPROGS_UNDO_DIR environment variable or the undo_dir direc‐
543 tive in the configuration file.
544
545 WARNING: The undo file cannot be used to recover from a power or
546 system crash.
547
549 MKE2FS_SYNC
550 If set to non-zero integer value, its value is used to determine
551 how often sync(2) is called during inode table initialization.
552
553 MKE2FS_CONFIG
554 Determines the location of the configuration file (see
555 mke2fs.conf(5)).
556
557 MKE2FS_FIRST_META_BG
558 If set to non-zero integer value, its value is used to determine
559 first meta block group. This is mostly for debugging purposes.
560
561 MKE2FS_DEVICE_SECTSIZE
562 If set to non-zero integer value, its value is used to determine
563 logical sector size of the device.
564
565 MKE2FS_DEVICE_PHYS_SECTSIZE
566 If set to non-zero integer value, its value is used to determine
567 physical sector size of the device.
568
569 MKE2FS_SKIP_CHECK_MSG
570 If set, do not show the message of file system automatic check
571 caused by mount count or check interval.
572
574 This version of mke2fs has been written by Theodore Ts'o
575 <tytso@mit.edu>.
576
578 mke2fs is part of the e2fsprogs package and is available from
579 http://e2fsprogs.sourceforge.net.
580
582 mke2fs.conf(5), badblocks(8), dumpe2fs(8), e2fsck(8), tune2fs(8),
583 ext4(5)
584
585
586
587E2fsprogs version 1.47.0 February 2023 MKE2FS(8)