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