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 no_copy_xattrs
180 Normally mke2fs will copy the extended attributes of
181 the files in the directory hierarchy specified via
182 the (optional) -d option. This will disable the
183 copy and leaves the files in the newly created file
184 system without any extended attributes.
185
186 num_backup_sb=<0|1|2>
187 If the sparse_super2 file system feature is enabled
188 this option controls whether there will be 0, 1, or
189 2 backup superblocks created in the file system.
190
191 packed_meta_blocks[= <0 to disable, 1 to enable>]
192 Place the allocation bitmaps and the inode table at
193 the beginning of the disk. This option requires
194 that the flex_bg file system feature to be enabled
195 in order for it to have effect, and will also create
196 the journal at the beginning of the file system.
197 This option is useful for flash devices that use SLC
198 flash at the beginning of the disk. It also maxi‐
199 mizes the range of contiguous data blocks, which can
200 be useful for certain specialized use cases, such as
201 supported Shingled Drives.
202
203 root_owner[=uid:gid]
204 Specify the numeric user and group ID of the root
205 directory. If no UID:GID is specified, use the user
206 and group ID of the user running mke2fs. In mke2fs
207 1.42 and earlier the UID and GID of the root direc‐
208 tory were set by default to the UID and GID of the
209 user running the mke2fs command. The root_owner=
210 option allows explicitly specifying these values,
211 and avoid side-effects for users that do not expect
212 the contents of the file system to change based on
213 the user running mke2fs.
214
215 test_fs
216 Set a flag in the file system superblock indicating
217 that it may be mounted using experimental kernel
218 code, such as the ext4dev file system.
219
220 discard
221 Attempt to discard blocks at mkfs time (discarding
222 blocks initially is useful on solid state devices
223 and sparse / thin-provisioned storage). When the de‐
224 vice advertises that discard also zeroes data (any
225 subsequent read after the discard and before write
226 returns zero), then mark all not-yet-zeroed inode
227 tables as zeroed. This significantly speeds up file
228 system initialization. This is set as default.
229
230 nodiscard
231 Do not attempt to discard blocks at mkfs time.
232
233 quotatype
234 Specify the which quota types (usrquota, grpquota,
235 prjquota) which should be enabled in the created
236 file system. The argument of this extended option
237 should be a colon separated list. This option has
238 effect only if the quota feature is set. The de‐
239 fault quota types to be initialized if this option
240 is not specified is both user and group quotas. If
241 the project feature is enabled that project quotas
242 will be initialized as well.
243
244 -F Force mke2fs to create a file system, even if the specified de‐
245 vice is not a partition on a block special device, or if other
246 parameters do not make sense. In order to force mke2fs to cre‐
247 ate a file system even if the file system appears to be in use
248 or is mounted (a truly dangerous thing to do), this option must
249 be specified twice.
250
251 -g blocks-per-group
252 Specify the number of blocks in a block group. There is gener‐
253 ally no reason for the user to ever set this parameter, as the
254 default is optimal for the file system. (For administrators who
255 are creating file systems on RAID arrays, it is preferable to
256 use the stride RAID parameter as part of the -E option rather
257 than manipulating the number of blocks per group.) This option
258 is generally used by developers who are developing test cases.
259
260 If the bigalloc feature is enabled, the -g option will specify
261 the number of clusters in a block group.
262
263 -G number-of-groups
264 Specify the number of block groups that will be packed together
265 to create a larger virtual block group (or "flex_bg group") in
266 an ext4 file system. This improves meta-data locality and per‐
267 formance on meta-data heavy workloads. The number of groups
268 must be a power of 2 and may only be specified if the flex_bg
269 file system feature is enabled.
270
271 -i bytes-per-inode
272 Specify the bytes/inode ratio. mke2fs creates an inode for ev‐
273 ery bytes-per-inode bytes of space on the disk. The larger the
274 bytes-per-inode ratio, the fewer inodes will be created. This
275 value generally shouldn't be smaller than the blocksize of the
276 file system, since in that case more inodes would be made than
277 can ever be used. Be warned that it is not possible to change
278 this ratio on a file system after it is created, so be careful
279 deciding the correct value for this parameter. Note that resiz‐
280 ing a file system changes the number of inodes to maintain this
281 ratio.
282
283 -I inode-size
284 Specify the size of each inode in bytes. The inode-size value
285 must be a power of 2 larger or equal to 128. The larger the in‐
286 ode-size the more space the inode table will consume, and this
287 reduces the usable space in the file system and can also nega‐
288 tively impact performance. It is not possible to change this
289 value after the file system is created.
290
291 File systems with an inode size of 128 bytes do not support
292 timestamps beyond January 19, 2038. Inodes which are 256 bytes
293 or larger will support extended timestamps, project id's, and
294 the ability to store some extended attributes in the inode table
295 for improved performance.
296
297 The default inode size is controlled by the mke2fs.conf(5) file.
298 In the mke2fs.conf file shipped with e2fsprogs, the default in‐
299 ode size is 256 bytes for most file systems, except for small
300 file systems where the inode size will be 128 bytes.
301
302 -j Create the file system with an ext3 journal. If the -J option
303 is not specified, the default journal parameters will be used to
304 create an appropriately sized journal (given the size of the
305 file system) stored within the file system. Note that you must
306 be using a kernel which has ext3 support in order to actually
307 make use of the journal.
308
309 -J journal-options
310 Create the ext3 journal using options specified on the command-
311 line. Journal options are comma separated, and may take an ar‐
312 gument using the equals ('=') sign. The following journal op‐
313 tions are supported:
314
315 size=journal-size
316 Create an internal journal (i.e., stored inside the
317 file system) of size journal-size megabytes. The
318 size of the journal must be at least 1024 file sys‐
319 tem blocks (i.e., 1MB if using 1k blocks, 4MB if us‐
320 ing 4k blocks, etc.) and may be no more than
321 10,240,000 file system blocks or half the total file
322 system size (whichever is smaller)
323
324 fast_commit_size=fast-commit-size
325 Create an additional fast commit journal area of
326 size fast-commit-size kilobytes. This option is
327 only valid if fast_commit feature is enabled on the
328 file system. If this option is not specified and if
329 fast_commit feature is turned on, fast commit area
330 size defaults to journal-size / 64 megabytes. The
331 total size of the journal with fast_commit feature
332 set is journal-size + ( fast-commit-size * 1024)
333 megabytes. The total journal size may be no more
334 than 10,240,000 file system blocks or half the total
335 file system size (whichever is smaller).
336
337 location=journal-location
338 Specify the location of the journal. The argument
339 journal-location can either be specified as a block
340 number, or if the number has a units suffix (e.g.,
341 'M', 'G', etc.) interpret it as the offset from the
342 beginning of the file system.
343
344 device=external-journal
345 Attach the file system to the journal block device
346 located on external-journal. The external journal
347 must already have been created using the command
348
349 mke2fs -O journal_dev external-journal
350
351 Note that external-journal must have been created
352 with the same block size as the new file system. In
353 addition, while there is support for attaching mul‐
354 tiple file systems to a single external journal, the
355 Linux kernel and e2fsck(8) do not currently support
356 shared external journals yet.
357
358 Instead of specifying a device name directly, exter‐
359 nal-journal can also be specified by either LA‐
360 BEL=label or UUID=UUID to locate the external jour‐
361 nal by either the volume label or UUID stored in the
362 ext2 superblock at the start of the journal. Use
363 dumpe2fs(8) to display a journal device's volume la‐
364 bel and UUID. See also the -L option of tune2fs(8).
365
366 Only one of the size or device options can be given for a file
367 system.
368
369 -l filename
370 Read the bad blocks list from filename. Note that the block
371 numbers in the bad block list must be generated using the same
372 block size as used by mke2fs. As a result, the -c option to
373 mke2fs is a much simpler and less error-prone method of checking
374 a disk for bad blocks before formatting it, as mke2fs will auto‐
375 matically pass the correct parameters to the badblocks program.
376
377 -L new-volume-label
378 Set the volume label for the file system to new-volume-label.
379 The maximum length of the volume label is 16 bytes.
380
381 -m reserved-blocks-percentage
382 Specify the percentage of the file system blocks reserved for
383 the super-user. This avoids fragmentation, and allows root-
384 owned daemons, such as syslogd(8), to continue to function cor‐
385 rectly after non-privileged processes are prevented from writing
386 to the file system. The default percentage is 5%.
387
388 -M last-mounted-directory
389 Set the last mounted directory for the file system. This might
390 be useful for the sake of utilities that key off of the last
391 mounted directory to determine where the file system should be
392 mounted.
393
394 -n Causes mke2fs to not actually create a file system, but display
395 what it would do if it were to create a file system. This can
396 be used to determine the location of the backup superblocks for
397 a particular file system, so long as the mke2fs parameters that
398 were passed when the file system was originally created are used
399 again. (With the -n option added, of course!)
400
401 -N number-of-inodes
402 Overrides the default calculation of the number of inodes that
403 should be reserved for the file system (which is based on the
404 number of blocks and the bytes-per-inode ratio). This allows
405 the user to specify the number of desired inodes directly.
406
407 -o creator-os
408 Overrides the default value of the "creator operating system"
409 field of the file system. The creator field is set by default
410 to the name of the OS the mke2fs executable was compiled for.
411
412 -O [^]feature[,...]
413 Create a file system with the given features (file system op‐
414 tions), overriding the default file system options. The fea‐
415 tures that are enabled by default are specified by the base_fea‐
416 tures relation, either in the [defaults] section in the
417 /etc/mke2fs.conf configuration file, or in the [fs_types] sub‐
418 sections for the usage types as specified by the -T option, fur‐
419 ther modified by the features relation found in the [fs_types]
420 subsections for the file system and usage types. See the
421 mke2fs.conf(5) manual page for more details. The file system
422 type-specific configuration setting found in the [fs_types] sec‐
423 tion will override the global default found in [defaults].
424
425 The file system feature set will be further edited using either
426 the feature set specified by this option, or if this option is
427 not given, by the default_features relation for the file system
428 type being created, or in the [defaults] section of the configu‐
429 ration file.
430
431 The file system feature set is comprised of a list of features,
432 separated by commas, that are to be enabled. To disable a fea‐
433 ture, simply prefix the feature name with a caret ('^') charac‐
434 ter. Features with dependencies will not be removed success‐
435 fully. The pseudo-file system feature "none" will clear all
436 file system features.
437
438 For more information about the features which can be set, please see
439 the manual page ext4(5).
440
441 -q Quiet execution. Useful if mke2fs is run in a script.
442
443 -r revision
444 Set the file system revision for the new file system. Note that
445 1.2 kernels only support revision 0 file systems. The default
446 is to create revision 1 file systems.
447
448 -S Write superblock and group descriptors only. This is an extreme
449 measure to be taken only in the very unlikely case that all of
450 the superblock and backup superblocks are corrupted, and a last-
451 ditch recovery method is desired by experienced users. It
452 causes mke2fs to reinitialize the superblock and group descrip‐
453 tors, while not touching the inode table and the block and inode
454 bitmaps. The e2fsck program should be run immediately after
455 this option is used, and there is no guarantee that any data
456 will be salvageable. Due to the wide variety of possible op‐
457 tions to mke2fs that affect the on-disk layout, it is critical
458 to specify exactly the same format options, such as blocksize,
459 fs-type, feature flags, and other tunables when using this op‐
460 tion, or the file system will be further corrupted. In some
461 cases, such as file systems that have been resized, or have had
462 features enabled after format time, it is impossible to over‐
463 write all of the superblocks correctly, and at least some file
464 system corruption will occur. It is best to run this on a full
465 copy of the file system so other options can be tried if this
466 doesn't work.
467
468 -t fs-type
469 Specify the file system type (i.e., ext2, ext3, ext4, etc.) that
470 is to be created. If this option is not specified, mke2fs will
471 pick a default either via how the command was run (for example,
472 using a name of the form mkfs.ext2, mkfs.ext3, etc.) or via a
473 default as defined by the /etc/mke2fs.conf file. This option
474 controls which file system options are used by default, based on
475 the fstypes configuration stanza in /etc/mke2fs.conf.
476
477 If the -O option is used to explicitly add or remove file system
478 options that should be set in the newly created file system, the
479 resulting file system may not be supported by the requested fs-
480 type. (e.g., "mke2fs -t ext3 -O extent /dev/sdXX" will create a
481 file system that is not supported by the ext3 implementation as
482 found in the Linux kernel; and "mke2fs -t ext3 -O ^has_journal
483 /dev/hdXX" will create a file system that does not have a jour‐
484 nal and hence will not be supported by the ext3 file system code
485 in the Linux kernel.)
486
487 -T usage-type[,...]
488 Specify how the file system is going to be used, so that mke2fs
489 can choose optimal file system parameters for that use. The us‐
490 age types that are supported are defined in the configuration
491 file /etc/mke2fs.conf. The user may specify one or more usage
492 types using a comma separated list.
493
494 If this option is is not specified, mke2fs will pick a single
495 default usage type based on the size of the file system to be
496 created. If the file system size is less than 3 megabytes,
497 mke2fs will use the file system type floppy. If the file system
498 size is greater than or equal to 3 but less than 512 megabytes,
499 mke2fs(8) will use the file system type small. If the file sys‐
500 tem size is greater than or equal to 4 terabytes but less than
501 16 terabytes, mke2fs(8) will use the file system type big. If
502 the file system size is greater than or equal to 16 terabytes,
503 mke2fs(8) will use the file system type huge. Otherwise,
504 mke2fs(8) will use the default file system type default.
505
506 -U UUID
507 Set the universally unique identifier (UUID) of the file system
508 to UUID. The format of the UUID is a series of hex digits sepa‐
509 rated by hyphens, like this:
510 "c1b9d5a2-f162-11cf-9ece-0020afc76f16". The UUID parameter may
511 also be one of the following:
512
513 clear clear the file system UUID
514
515 random generate a new randomly-generated UUID
516
517 time generate a new time-based UUID
518
519 -v Verbose execution.
520
521 -V Print the version number of mke2fs and exit.
522
523 -z undo_file
524 Before overwriting a file system block, write the old contents
525 of the block to an undo file. This undo file can be used with
526 e2undo(8) to restore the old contents of the file system should
527 something go wrong. If the empty string is passed as the
528 undo_file argument, the undo file will be written to a file
529 named mke2fs-device.e2undo in the directory specified via the
530 E2FSPROGS_UNDO_DIR environment variable or the undo_dir direc‐
531 tive in the configuration file.
532
533 WARNING: The undo file cannot be used to recover from a power or
534 system crash.
535
537 MKE2FS_SYNC
538 If set to non-zero integer value, its value is used to determine
539 how often sync(2) is called during inode table initialization.
540
541 MKE2FS_CONFIG
542 Determines the location of the configuration file (see
543 mke2fs.conf(5)).
544
545 MKE2FS_FIRST_META_BG
546 If set to non-zero integer value, its value is used to determine
547 first meta block group. This is mostly for debugging purposes.
548
549 MKE2FS_DEVICE_SECTSIZE
550 If set to non-zero integer value, its value is used to determine
551 logical sector size of the device.
552
553 MKE2FS_DEVICE_PHYS_SECTSIZE
554 If set to non-zero integer value, its value is used to determine
555 physical sector size of the device.
556
557 MKE2FS_SKIP_CHECK_MSG
558 If set, do not show the message of file system automatic check
559 caused by mount count or check interval.
560
562 This version of mke2fs has been written by Theodore Ts'o
563 <tytso@mit.edu>.
564
566 mke2fs is part of the e2fsprogs package and is available from
567 http://e2fsprogs.sourceforge.net.
568
570 mke2fs.conf(5), badblocks(8), dumpe2fs(8), e2fsck(8), tune2fs(8),
571 ext4(5)
572
573
574
575E2fsprogs version 1.46.5 December 2021 MKE2FS(8)