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