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 File systems with an inode size of 128 bytes do not support
287 timestamps beyond January 19, 2038. Inodes which are 256 bytes
288 or larger will support extended timestamps, project id's, and
289 the ability to store some extended attributes in the inode table
290 for improved performance.
291
292 The default inode size is controlled by the mke2fs.conf(5) file.
293 In the mke2fs.conf file shipped with e2fsprogs, the default
294 inode size is 256 bytes for most file systems, except for small
295 file systems where the inode size will be 128 bytes.
296
297 -j Create the filesystem with an ext3 journal. If the -J option is
298 not specified, the default journal parameters will be used to
299 create an appropriately sized journal (given the size of the
300 filesystem) stored within the filesystem. Note that you must be
301 using a kernel which has ext3 support in order to actually make
302 use of the journal.
303
304 -J journal-options
305 Create the ext3 journal using options specified on the command-
306 line. Journal options are comma separated, and may take an
307 argument using the equals ('=') sign. The following journal
308 options are supported:
309
310 size=journal-size
311 Create an internal journal (i.e., stored inside the
312 filesystem) of size journal-size megabytes. The
313 size of the journal must be at least 1024 filesystem
314 blocks (i.e., 1MB if using 1k blocks, 4MB if using
315 4k blocks, etc.) and may be no more than 10,240,000
316 filesystem blocks or half the total file system size
317 (whichever is smaller)
318
319 location=journal-location
320 Specify the location of the journal. The argument
321 journal-location can either be specified as a block
322 number, or if the number has a units suffix (e.g.,
323 'M', 'G', etc.) interpret it as the offset from the
324 beginning of the file system.
325
326 device=external-journal
327 Attach the filesystem to the journal block device
328 located on external-journal. The external journal
329 must already have been created using the command
330
331 mke2fs -O journal_dev external-journal
332
333 Note that external-journal must have been created
334 with the same block size as the new filesystem. In
335 addition, while there is support for attaching mul‐
336 tiple filesystems to a single external journal, the
337 Linux kernel and e2fsck(8) do not currently support
338 shared external journals yet.
339
340 Instead of specifying a device name directly, exter‐
341 nal-journal can also be specified by either
342 LABEL=label or UUID=UUID to locate the external
343 journal by either the volume label or UUID stored in
344 the ext2 superblock at the start of the journal.
345 Use dumpe2fs(8) to display a journal device's volume
346 label and UUID. See also the -L option of
347 tune2fs(8).
348
349 Only one of the size or device options can be given for a
350 filesystem.
351
352 -l filename
353 Read the bad blocks list from filename. Note that the block
354 numbers in the bad block list must be generated using the same
355 block size as used by mke2fs. As a result, the -c option to
356 mke2fs is a much simpler and less error-prone method of checking
357 a disk for bad blocks before formatting it, as mke2fs will auto‐
358 matically pass the correct parameters to the badblocks program.
359
360 -L new-volume-label
361 Set the volume label for the filesystem to new-volume-label.
362 The maximum length of the volume label is 16 bytes.
363
364 -m reserved-blocks-percentage
365 Specify the percentage of the filesystem blocks reserved for the
366 super-user. This avoids fragmentation, and allows root-owned
367 daemons, such as syslogd(8), to continue to function correctly
368 after non-privileged processes are prevented from writing to the
369 filesystem. The default percentage is 5%.
370
371 -M last-mounted-directory
372 Set the last mounted directory for the filesystem. This might
373 be useful for the sake of utilities that key off of the last
374 mounted directory to determine where the filesystem should be
375 mounted.
376
377 -n Causes mke2fs to not actually create a filesystem, but display
378 what it would do if it were to create a filesystem. This can be
379 used to determine the location of the backup superblocks for a
380 particular filesystem, so long as the mke2fs parameters that
381 were passed when the filesystem was originally created are used
382 again. (With the -n option added, of course!)
383
384 -N number-of-inodes
385 Overrides the default calculation of the number of inodes that
386 should be reserved for the filesystem (which is based on the
387 number of blocks and the bytes-per-inode ratio). This allows
388 the user to specify the number of desired inodes directly.
389
390 -o creator-os
391 Overrides the default value of the "creator operating system"
392 field of the filesystem. The creator field is set by default to
393 the name of the OS the mke2fs executable was compiled for.
394
395 -O [^]feature[,...]
396 Create a filesystem with the given features (filesystem
397 options), overriding the default filesystem options. The fea‐
398 tures that are enabled by default are specified by the base_fea‐
399 tures relation, either in the [defaults] section in the
400 /etc/mke2fs.conf configuration file, or in the [fs_types] sub‐
401 sections for the usage types as specified by the -T option, fur‐
402 ther modified by the features relation found in the [fs_types]
403 subsections for the filesystem and usage types. See the
404 mke2fs.conf(5) manual page for more details. The filesystem
405 type-specific configuration setting found in the [fs_types] sec‐
406 tion will override the global default found in [defaults].
407
408 The filesystem feature set will be further edited using either
409 the feature set specified by this option, or if this option is
410 not given, by the default_features relation for the filesystem
411 type being created, or in the [defaults] section of the configu‐
412 ration file.
413
414 The filesystem feature set is comprised of a list of features,
415 separated by commas, that are to be enabled. To disable a fea‐
416 ture, simply prefix the feature name with a caret ('^') charac‐
417 ter. Features with dependencies will not be removed success‐
418 fully. The pseudo-filesystem feature "none" will clear all
419 filesystem features.
420
421 For more information about the features which can be set, please see
422 the manual page ext4(5).
423
424 -q Quiet execution. Useful if mke2fs is run in a script.
425
426 -r revision
427 Set the filesystem revision for the new filesystem. Note that
428 1.2 kernels only support revision 0 filesystems. The default is
429 to create revision 1 filesystems.
430
431 -S Write superblock and group descriptors only. This is an extreme
432 measure to be taken only in the very unlikely case that all of
433 the superblock and backup superblocks are corrupted, and a last-
434 ditch recovery method is desired by experienced users. It
435 causes mke2fs to reinitialize the superblock and group descrip‐
436 tors, while not touching the inode table and the block and inode
437 bitmaps. The e2fsck program should be run immediately after
438 this option is used, and there is no guarantee that any data
439 will be salvageable. Due to the wide variety of possible
440 options to mke2fs that affect the on-disk layout, it is critical
441 to specify exactly the same format options, such as blocksize,
442 fs-type, feature flags, and other tunables when using this
443 option, or the filesystem will be further corrupted. In some
444 cases, such as filesystems that have been resized, or have had
445 features enabled after format time, it is impossible to over‐
446 write all of the superblocks correctly, and at least some
447 filesystem corruption will occur. It is best to run this on a
448 full copy of the filesystem so other options can be tried if
449 this doesn't work.
450
451 -t fs-type
452 Specify the filesystem type (i.e., ext2, ext3, ext4, etc.) that
453 is to be created. If this option is not specified, mke2fs will
454 pick a default either via how the command was run (for example,
455 using a name of the form mkfs.ext2, mkfs.ext3, etc.) or via a
456 default as defined by the /etc/mke2fs.conf file. This option
457 controls which filesystem options are used by default, based on
458 the fstypes configuration stanza in /etc/mke2fs.conf.
459
460 If the -O option is used to explicitly add or remove filesystem
461 options that should be set in the newly created filesystem, the
462 resulting filesystem may not be supported by the requested fs-
463 type. (e.g., "mke2fs -t ext3 -O extent /dev/sdXX" will create a
464 filesystem that is not supported by the ext3 implementation as
465 found in the Linux kernel; and "mke2fs -t ext3 -O ^has_journal
466 /dev/hdXX" will create a filesystem that does not have a journal
467 and hence will not be supported by the ext3 filesystem code in
468 the Linux kernel.)
469
470 -T usage-type[,...]
471 Specify how the filesystem is going to be used, so that mke2fs
472 can choose optimal filesystem parameters for that use. The
473 usage types that are supported are defined in the configuration
474 file /etc/mke2fs.conf. The user may specify one or more usage
475 types using a comma separated list.
476
477 If this option is is not specified, mke2fs will pick a single
478 default usage type based on the size of the filesystem to be
479 created. If the filesystem size is less than 3 megabytes,
480 mke2fs will use the filesystem type floppy. If the filesystem
481 size is greater than or equal to 3 but less than 512 megabytes,
482 mke2fs(8) will use the filesystem type small. If the filesystem
483 size is greater than or equal to 4 terabytes but less than 16
484 terabytes, mke2fs(8) will use the filesystem type big. If the
485 filesystem size is greater than or equal to 16 terabytes,
486 mke2fs(8) will use the filesystem type huge. Otherwise,
487 mke2fs(8) will use the default filesystem type default.
488
489 -U UUID
490 Set the universally unique identifier (UUID) of the filesystem
491 to UUID. The format of the UUID is a series of hex digits sepa‐
492 rated by hyphens, like this:
493 "c1b9d5a2-f162-11cf-9ece-0020afc76f16". The UUID parameter may
494 also be one of the following:
495
496 clear clear the filesystem UUID
497
498 random generate a new randomly-generated UUID
499
500 time generate a new time-based UUID
501
502 -v Verbose execution.
503
504 -V Print the version number of mke2fs and exit.
505
506 -z undo_file
507 Before overwriting a file system block, write the old contents
508 of the block to an undo file. This undo file can be used with
509 e2undo(8) to restore the old contents of the file system should
510 something go wrong. If the empty string is passed as the
511 undo_file argument, the undo file will be written to a file
512 named mke2fs-device.e2undo in the directory specified via the
513 E2FSPROGS_UNDO_DIR environment variable or the undo_dir direc‐
514 tive in the configuration file.
515
516 WARNING: The undo file cannot be used to recover from a power or
517 system crash.
518
520 MKE2FS_SYNC
521 If set to non-zero integer value, its value is used to determine
522 how often sync(2) is called during inode table initialization.
523
524 MKE2FS_CONFIG
525 Determines the location of the configuration file (see
526 mke2fs.conf(5)).
527
528 MKE2FS_FIRST_META_BG
529 If set to non-zero integer value, its value is used to determine
530 first meta block group. This is mostly for debugging purposes.
531
532 MKE2FS_DEVICE_SECTSIZE
533 If set to non-zero integer value, its value is used to determine
534 logical sector size of the device.
535
536 MKE2FS_DEVICE_PHYS_SECTSIZE
537 If set to non-zero integer value, its value is used to determine
538 physical sector size of the device.
539
540 MKE2FS_SKIP_CHECK_MSG
541 If set, do not show the message of filesystem automatic check
542 caused by mount count or check interval.
543
545 This version of mke2fs has been written by Theodore Ts'o
546 <tytso@mit.edu>.
547
549 mke2fs is part of the e2fsprogs package and is available from
550 http://e2fsprogs.sourceforge.net.
551
553 mke2fs.conf(5), badblocks(8), dumpe2fs(8), e2fsck(8), tune2fs(8),
554 ext4(5)
555
556
557
558E2fsprogs version 1.45.6 March 2020 MKE2FS(8)