blob: fea50da1896f770d3b9128d66882096d1aaeeba0 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001.\" -*- nroff -*-
2.\" Copyright 1993, 1994, 1995 by Theodore Ts'o. All Rights Reserved.
3.\" This file may be copied under the terms of the GNU Public License.
4.\"
5.TH MKE2FS 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
6.SH NAME
7mke2fs \- create an ext2/ext3/ext4 filesystem
8.SH SYNOPSIS
9.B mke2fs
10[
11.B \-c
12|
13.B \-l
14.I filename
15]
16[
17.B \-b
18.I block-size
19]
20[
21.B \-D
22]
23[
24.B \-f
25.I fragment-size
26]
27[
28.B \-g
29.I blocks-per-group
30]
31[
32.B \-G
33.I number-of-groups
34]
35[
36.B \-i
37.I bytes-per-inode
38]
39[
40.B \-I
41.I inode-size
42]
43[
44.B \-j
45]
46[
47.B \-J
48.I journal-options
49]
50[
51.B \-N
52.I number-of-inodes
53]
54[
55.B \-n
56]
57[
58.B \-m
59.I reserved-blocks-percentage
60]
61[
62.B \-o
63.I creator-os
64]
65[
66.B \-O
67.IR feature [,...]
68]
69[
70.B \-q
71]
72[
73.B \-r
74.I fs-revision-level
75]
76[
77.B \-E
78.I extended-options
79]
80[
81.B \-v
82]
83[
84.B \-F
85]
86[
87.B \-L
88.I volume-label
89]
90[
91.B \-M
92.I last-mounted-directory
93]
94[
95.B \-S
96]
97[
98.B \-t
99.I fs-type
100]
101[
102.B \-T
103.I usage-type
104]
105[
106.B \-U
107.I UUID
108]
109[
110.B \-V
111]
112.I device
113[
114.I blocks-count
115]
116@JDEV@.sp
117@JDEV@.B "mke2fs \-O journal_dev"
118@JDEV@[
119@JDEV@.B \-b
120@JDEV@.I block-size
121@JDEV@]
122.\" No external-journal specific journal options yet (size is ignored)
123.\" @JDEV@[
124.\" @JDEV@.B \-J
125.\" @JDEV@.I journal-options
126.\" @JDEV@]
127@JDEV@[
128@JDEV@.B \-L
129@JDEV@.I volume-label
130@JDEV@]
131@JDEV@[
132@JDEV@.B \-n
133@JDEV@]
134@JDEV@[
135@JDEV@.B \-q
136@JDEV@]
137@JDEV@[
138@JDEV@.B \-v
139@JDEV@]
140@JDEV@.I external-journal
141@JDEV@[
142@JDEV@.I blocks-count
143@JDEV@]
144.SH DESCRIPTION
145.B mke2fs
146is used to create an ext2, ext3, or ext4 filesystem, usually in a disk
147partition.
148.I device
149is the special file corresponding to the device (e.g
150.IR /dev/hdXX ).
151.I blocks-count
152is the number of blocks on the device. If omitted,
153.B mke2fs
154automagically figures the file system size. If called as
155.B mkfs.ext3
156a journal is created as if the
157.B \-j
158option was specified.
159.PP
160The defaults of the parameters for the newly created filesystem, if not
161overridden by the options listed below, are controlled by the
162.B /etc/mke2fs.conf
163configuration file. See the
164.BR mke2fs.conf (5)
165manual page for more details.
166.SH OPTIONS
167.TP
168.BI \-b " block-size"
169Specify the size of blocks in bytes. Valid block-size values are 1024,
1702048 and 4096 bytes per block. If omitted,
171block-size is heuristically determined by the filesystem size and
172the expected usage of the filesystem (see the
173.B \-T
174option). If
175.I block-size
176is preceded by a negative sign ('-'), then
177.B mke2fs
178will use heuristics to determine the
179appropriate block size, with the constraint that the block size will be
180at least
181.I block-size
182bytes. This is useful for certain hardware devices which require that
183the blocksize be a multiple of 2k.
184.TP
185.B \-c
186Check the device for bad blocks before creating the file system. If
187this option is specified twice, then a slower read-write
188test is used instead of a fast read-only test.
189.TP
190.B \-C " cluster-size"
191Specify the size of cluster in bytes for filesystems using the bigalloc
192feature. Valid cluster-size values are from 2048 to 256M bytes per
193cluster. This can only be specified if the bigalloc feature is
194enabled. (See the
195.B ext4 (5)
196man page for more details about bigalloc.) The default cluster size if
197bigalloc is enabled is 16 times the block size.
198.TP
199.B \-D
200Use direct I/O when writing to the disk. This avoids mke2fs dirtying a
201lot of buffer cache memory, which may impact other applications running
202on a busy server. This option will cause mke2fs to run much more
203slowly, however, so there is a tradeoff to using direct I/O.
204.TP
205.BI \-E " extended-options"
206Set extended options for the filesystem. Extended options are comma
207separated, and may take an argument using the equals ('=') sign. The
208.B \-E
209option used to be
210.B \-R
211in earlier versions of
212.BR mke2fs .
213The
214.B \-R
215option is still accepted for backwards compatibility, but is deprecated.
216The following extended options are supported:
217.RS 1.2i
218.TP
219.BI mmp_update_interval= interval
220Adjust the initial MMP update interval to
221.I interval
222seconds. Specifying an
223.I interval
224of 0 means to use the default interval. The specified interval must
225be less than 300 seconds. Requires that the
226.B mmp
227feature be enabled.
228.TP
229.BI stride= stride-size
230Configure the filesystem for a RAID array with
231.I stride-size
232filesystem blocks. This is the number of blocks read or written to disk
233before moving to the next disk, which is sometimes referred to as the
234.I chunk size.
235This mostly affects placement of filesystem metadata like bitmaps at
236.B mke2fs
237time to avoid placing them on a single disk, which can hurt performance.
238It may also be used by the block allocator.
239.TP
240.BI stripe_width= stripe-width
241Configure the filesystem for a RAID array with
242.I stripe-width
243filesystem blocks per stripe. This is typically stride-size * N, where
244N is the number of data-bearing disks in the RAID (e.g. for RAID 5 there is one
245parity disk, so N will be the number of disks in the array minus 1).
246This allows the block allocator to prevent read-modify-write of the
247parity in a RAID stripe if possible when the data is written.
248.TP
249.BI resize= max-online-resize
250Reserve enough space so that the block group descriptor table can grow
251to support a filesystem that has
252.I max-online-resize
253blocks.
254.TP
255.B lazy_itable_init\fR[\fB= \fI<0 to disable, 1 to enable>\fR]
256If enabled and the uninit_bg feature is enabled, the inode table will
257not be fully initialized by
258.BR mke2fs .
259This speeds up filesystem
260initialization noticeably, but it requires the kernel to finish
261initializing the filesystem in the background when the filesystem is
262first mounted. If the option value is omitted, it defaults to 1 to
263enable lazy inode table zeroing.
264.TP
265.B lazy_journal_init\fR[\fB= \fI<0 to disable, 1 to enable>\fR]
266If enabled, the journal inode will not be fully zeroed out by
267.BR mke2fs .
268This speeds up filesystem initialization noticeably, but carries some
269small risk if the system crashes before the journal has been overwritten
270entirely one time. If the option value is omitted, it defaults to 1 to
271enable lazy journal inode zeroing.
272.TP
273.BI root_owner [=uid:gid]
274Specify the numeric user and group ID of the root directory. If no UID:GID
275is specified, use the user and group ID of the user running \fBmke2fs\fR.
276In \fBmke2fs\fR 1.42 and earlier the UID and GID of the root directory were
277set by default to the UID and GID of the user running the mke2fs command.
278The \fBroot_owner=\fR option allows explicitly specifying these values,
279and avoid side-effects for users that do not expect the contents of the
280filesystem to change based on the user running \fBmke2fs\fR.
281.TP
282.B test_fs
283Set a flag in the filesystem superblock indicating that it may be
284mounted using experimental kernel code, such as the ext4dev filesystem.
285.TP
286.BI discard
287Attempt to discard blocks at mkfs time (discarding blocks initially is useful
288on solid state devices and sparse / thin-provisioned storage). When the device
289advertises that discard also zeroes data (any subsequent read after the discard
290and before write returns zero), then mark all not-yet-zeroed inode tables as
291zeroed. This significantly speeds up filesystem initialization. This is set
292as default.
293.TP
294.BI nodiscard
295Do not attempt to discard blocks at mkfs time.
296@QUOTA_MAN_COMMENT@.TP
297@QUOTA_MAN_COMMENT@.BI quotatype
298@QUOTA_MAN_COMMENT@Specify which quota type ('usr' or 'grp') is to be
299@QUOTA_MAN_COMMENT@initialized. This option has effect only if the
300@QUOTA_MAN_COMMENT@.B quota
301@QUOTA_MAN_COMMENT@feature is set. Without this extended option, the default
302@QUOTA_MAN_COMMENT@behavior is to initialize both user and group quotas.
303.RE
304.TP
305.BI \-f " fragment-size"
306Specify the size of fragments in bytes.
307.TP
308.B \-F
309Force
310.B mke2fs
311to create a filesystem, even if the specified device is not a partition
312on a block special device, or if other parameters do not make sense.
313In order to force
314.B mke2fs
315to create a filesystem even if the filesystem appears to be in use
316or is mounted (a truly dangerous thing to do), this option must be
317specified twice.
318.TP
319.BI \-g " blocks-per-group"
320Specify the number of blocks in a block group. There is generally no
321reason for the user to ever set this parameter, as the default is optimal
322for the filesystem. (For administrators who are creating
323filesystems on RAID arrays, it is preferable to use the
324.I stride
325RAID parameter as part of the
326.B \-E
327option rather than manipulating the number of blocks per group.)
328This option is generally used by developers who
329are developing test cases.
330.IP
331If the bigalloc feature is enabled, the
332.B \-g
333option will specify the number of clusters in a block group.
334.TP
335.BI \-G " number-of-groups"
336Specify the number of block groups that will be packed together to
337create a larger virtual block group (or "flex_bg group") in an
338ext4 filesystem. This improves meta-data locality and performance
339on meta-data heavy workloads. The number of groups must be a power
340of 2 and may only be specified if the
341.B flex_bg
342filesystem feature is enabled.
343.TP
344.BI \-i " bytes-per-inode"
345Specify the bytes/inode ratio.
346.B mke2fs
347creates an inode for every
348.I bytes-per-inode
349bytes of space on the disk. The larger the
350.I bytes-per-inode
351ratio, the fewer inodes will be created. This value generally shouldn't
352be smaller than the blocksize of the filesystem, since in that case more
353inodes would be made than can ever be used. Be warned that it is not
354possible to change this ratio on a filesystem after it is created, so be
355careful deciding the correct value for this parameter. Note that resizing
356a filesystem changes the numer of inodes to maintain this ratio.
357.TP
358.BI \-I " inode-size"
359Specify the size of each inode in bytes.
360The
361.I inode-size
362value must be a power of 2 larger or equal to 128. The larger the
363.I inode-size
364the more space the inode table will consume, and this reduces the usable
365space in the filesystem and can also negatively impact performance.
366It is not
367possible to change this value after the filesystem is created.
368.IP
369In kernels after 2.6.10 and some
370earlier vendor kernels it is possible to utilize inodes larger than
371128 bytes to store
372extended attributes for improved performance.
373Extended attributes
374stored in large inodes are not visible with older kernels, and such
375filesystems will not be mountable with 2.4 kernels at all.
376.IP
377The default inode size is controlled by the
378.BR mke2fs.conf (5)
379file. In the
380.B mke2fs.conf
381file shipped with e2fsprogs, the default inode size is 256 bytes for
382most file systems, except for small file systems where the inode size
383will be 128 bytes.
384.TP
385.B \-j
386Create the filesystem with an ext3 journal. If the
387.B \-J
388option is not specified, the default journal parameters will be used to
389create an appropriately sized journal (given the size of the filesystem)
390stored within the filesystem. Note that you must be using a kernel
391which has ext3 support in order to actually make use of the journal.
392.TP
393.BI \-J " journal-options"
394Create the ext3 journal using options specified on the command-line.
395Journal options are comma
396separated, and may take an argument using the equals ('=') sign.
397The following journal options are supported:
398.RS 1.2i
399.TP
400.BI size= journal-size
401Create an internal journal (i.e., stored inside the filesystem) of size
402.I journal-size
403megabytes.
404The size of the journal must be at least 1024 filesystem blocks
405(i.e., 1MB if using 1k blocks, 4MB if using 4k blocks, etc.)
406and may be no more than 10,240,000 filesystem blocks or half the total
407file system size (whichever is smaller)
408@JDEV@.TP
409@JDEV@.BI device= external-journal
410@JDEV@Attach the filesystem to the journal block device located on
411@JDEV@.IR external-journal .
412@JDEV@The external
413@JDEV@journal must already have been created using the command
414@JDEV@.IP
415@JDEV@.B mke2fs -O journal_dev
416@JDEV@.I external-journal
417@JDEV@.IP
418@JDEV@Note that
419@JDEV@.I external-journal
420@JDEV@must have been created with the
421@JDEV@same block size as the new filesystem.
422@JDEV@In addition, while there is support for attaching
423@JDEV@multiple filesystems to a single external journal,
424@JDEV@the Linux kernel and
425@JDEV@.BR e2fsck (8)
426@JDEV@do not currently support shared external journals yet.
427@JDEV@.IP
428@JDEV@Instead of specifying a device name directly,
429@JDEV@.I external-journal
430@JDEV@can also be specified by either
431@JDEV@.BI LABEL= label
432@JDEV@or
433@JDEV@.BI UUID= UUID
434@JDEV@to locate the external journal by either the volume label or UUID
435@JDEV@stored in the ext2 superblock at the start of the journal. Use
436@JDEV@.BR dumpe2fs (8)
437@JDEV@to display a journal device's volume label and UUID. See also the
438@JDEV@.B -L
439@JDEV@option of
440@JDEV@.BR tune2fs (8).
441.RE
442@JDEV@.IP
443@JDEV@Only one of the
444@JDEV@.BR size " or " device
445@JDEV@options can be given for a filesystem.
446.TP
447.BI \-l " filename"
448Read the bad blocks list from
449.IR filename .
450Note that the block numbers in the bad block list must be generated
451using the same block size as used by
452.BR mke2fs .
453As a result, the
454.B \-c
455option to
456.B mke2fs
457is a much simpler and less error-prone method of checking a disk for bad
458blocks before formatting it, as
459.B mke2fs
460will automatically pass the correct parameters to the
461.B badblocks
462program.
463.TP
464.BI \-L " new-volume-label"
465Set the volume label for the filesystem to
466.IR new-volume-label .
467The maximum length of the
468volume label is 16 bytes.
469.TP
470.BI \-m " reserved-blocks-percentage"
471Specify the percentage of the filesystem blocks reserved for
472the super-user. This avoids fragmentation, and allows root-owned
473daemons, such as
474.BR syslogd (8),
475to continue to function correctly after non-privileged processes are
476prevented from writing to the filesystem. The default percentage
477is 5%.
478.TP
479.BI \-M " last-mounted-directory"
480Set the last mounted directory for the filesystem. This might be useful
481for the sake of utilities that key off of the last mounted directory to
482determine where the filesystem should be mounted.
483.TP
484.B \-n
485Causes
486.B mke2fs
487to not actually create a filesystem, but display what it
488would do if it were to create a filesystem. This can be used to
489determine the location of the backup superblocks for a particular
490filesystem, so long as the
491.B mke2fs
492parameters that were passed when the
493filesystem was originally created are used again. (With the
494.B \-n
495option added, of course!)
496.TP
497.BI \-N " number-of-inodes"
498Overrides the default calculation of the number of inodes that should be
499reserved for the filesystem (which is based on the number of blocks and
500the
501.I bytes-per-inode
502ratio). This allows the user to specify the number
503of desired inodes directly.
504.TP
505.BI \-o " creator-os"
506Overrides the default value of the "creator operating system" field of the
507filesystem. The creator field is set by default to the name of the OS the
508.B mke2fs
509executable was compiled for.
510.TP
511.B "\-O \fIfeature\fR[,...]"
512Create a filesystem with the given features (filesystem options),
513overriding the default filesystem options. The features that are
514enabled by default are specified by the
515.I base_features
516relation, either in the
517.I [defaults]
518section in the
519.B /etc/mke2fs.conf
520configuration file,
521or in the
522.I [fs_types]
523subsections for the usage types as specified by the
524.B \-T
525option, further modified by the
526.I features
527relation found in the
528.I [fs_types]
529subsections for the filesystem and usage types. See the
530.BR mke2fs.conf (5)
531manual page for more details.
532The filesystem type-specific configuration setting found in the
533.I [fs_types]
534section will override the global default found in
535.IR [defaults] .
536.sp
537The filesystem feature set will be further edited
538using either the feature set specified by this option,
539or if this option is not given, by the
540.I default_features
541relation for the filesystem type being created, or in the
542.I [defaults]
543section of the configuration file.
544.sp
545The filesystem feature set is comprised of a list of features, separated
546by commas, that are to be enabled. To disable a feature, simply
547prefix the feature name with a caret ('^') or a minus ('-') character.
548Features with dependencies will not be removed successfully.
549The pseudo-filesystem feature "none" will clear all filesystem features.
550.TP
551For more information about the features which can be set, please see
552the manual page
553.BR ext4 (5).
554.TP
555.B \-q
556Quiet execution. Useful if
557.B mke2fs
558is run in a script.
559.TP
560.BI \-r " revision"
561Set the filesystem revision for the new filesystem. Note that 1.2
562kernels only support revision 0 filesystems. The default is to
563create revision 1 filesystems.
564.TP
565.B \-S
566Write superblock and group descriptors only. This is useful if all of
567the superblock and backup superblocks are corrupted, and a last-ditch
568recovery method is desired. It causes
569.B mke2fs
570to reinitialize the
571superblock and group descriptors, while not touching the inode table
572and the block and inode bitmaps. The
573.B e2fsck
574program should be run immediately after this option is used, and there
575is no guarantee that any data will be salvageable. It is critical to
576specify the correct filesystem blocksize when using this option,
577or there is no chance of recovery.
578.\" .TP
579.\" .BI \-t " test"
580.\" Check the device for bad blocks before creating the file system
581.\" using the specified test.
582.TP
583.BI \-t " fs-type"
584Specify the filesystem type (i.e., ext2, ext3, ext4, etc.) that is
585to be created.
586If this option is not specified,
587.B mke2fs
588will pick a default either via how
589the command was run (for example, using a name of the form mkfs.ext2,
590mkfs.ext3, etc.) or via a default as defined by the
591.B /etc/mke2fs.conf
592file. This option controls which filesystem options are used by
593default, based on the
594.B fstypes
595configuration stanza in
596.BR /etc/mke2fs.conf .
597.sp
598If the
599.B \-O
600option is used to explicitly add or remove filesystem options that
601should be set in the newly created filesystem, the
602resulting filesystem may not be supported by the requested
603.IR fs-type .
604(e.g., "\fBmke2fs \-t ext3 \-O extent /dev/sdXX\fR" will create a
605filesystem that is not supported by the ext3 implementation as found in
606the Linux kernel; and "\fBmke2fs \-t ext3 \-O ^has_journal /dev/hdXX\fR"
607will create a filesystem that does not have a journal and hence will not
608be supported by the ext3 filesystem code in the Linux kernel.)
609.TP
610.BI \-T " usage-type[,...]"
611Specify how the filesystem is going to be used, so that
612.B mke2fs
613can choose optimal filesystem parameters for that use. The usage
614types that are supported are defined in the configuration file
615.BR /etc/mke2fs.conf .
616The user may specify one or more usage types
617using a comma separated list.
618.sp
619If this option is is not specified,
620.B mke2fs
621will pick a single default usage type based on the size of the filesystem to
622be created. If the filesystem size is less than or equal to 3 megabytes,
623.B mke2fs
624will use the filesystem type
625.IR floppy .
626If the filesystem size is greater than 3 but less than or equal to
627512 megabytes,
628.BR mke2fs (8)
629will use the filesystem type
630.IR small .
631If the filesystem size is greater than or equal to 4 terabytes but less than
63216 terabytes,
633.BR mke2fs (8)
634will use the filesystem type
635.IR big .
636If the filesystem size is greater than or equal to 16 terabytes,
637.BR mke2fs (8)
638will use the filesystem type
639.IR huge .
640Otherwise,
641.BR mke2fs (8)
642will use the default filesystem type
643.IR default .
644.TP
645.BI \-U " UUID"
646Create the filesystem with the specified UUID.
647.TP
648.B \-v
649Verbose execution.
650.TP
651.B \-V
652Print the version number of
653.B mke2fs
654and exit.
655.SH ENVIRONMENT
656.TP
657.BI MKE2FS_SYNC
658If set to non-zero integer value, its value is used to determine how often
659.BR sync (2)
660is called during inode table initialization.
661.TP
662.BI MKE2FS_CONFIG
663Determines the location of the configuration file (see
664.BR mke2fs.conf (5)).
665.TP
666.BI MKE2FS_FIRST_META_BG
667If set to non-zero integer value, its value is used to determine first meta
668block group. This is mostly for debugging purposes.
669.TP
670.BI MKE2FS_DEVICE_SECTSIZE
671If set to non-zero integer value, its value is used to determine physical
672sector size of the
673.IR device .
674.TP
675.BI MKE2FS_SKIP_CHECK_MSG
676If set, do not show the message of filesystem automatic check caused by
677mount count or check interval.
678.SH AUTHOR
679This version of
680.B mke2fs
681has been written by Theodore Ts'o <tytso@mit.edu>.
682.SH BUGS
683.B mke2fs
684accepts the
685.B \-f
686option but currently ignores it because the second
687extended file system does not support fragments yet.
688.br
689There may be other ones. Please, report them to the author.
690.SH AVAILABILITY
691.B mke2fs
692is part of the e2fsprogs package and is available from
693http://e2fsprogs.sourceforge.net.
694.SH SEE ALSO
695.BR mke2fs.conf (5),
696.BR badblocks (8),
697.BR dumpe2fs (8),
698.BR e2fsck (8),
699.BR tune2fs (8),
700.BR ext4 (5)