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 ] [ -f fragment-size ] [ -g
10 blocks-per-group ] [ -G number-of-groups ] [ -i bytes-per-inode ] [ -I
11 inode-size ] [ -j ] [ -J journal-options ] [ -K ] [ -N number-of-inodes
12 ] [ -n ] [ -m reserved-blocks-percentage ] [ -o creator-os ] [ -O fea‐
13 ture[,...] ] [ -q ] [ -r fs-revision-level ] [ -E extended-options ] [
14 -v ] [ -F ] [ -L volume-label ] [ -M last-mounted-directory ] [ -S ] [
15 -t fs-type ] [ -T usage-type ] [ -U UUID ] [ -V ] device [ blocks-count
16 ]
17
18 mke2fs -O journal_dev [ -b block-size ] [ -L volume-label ] [ -n ] [ -q
19 ] [ -v ] external-journal [ blocks-count ]
20
22 mke2fs is used to create an ext2, ext3, or ext4 filesystem, usually in
23 a disk partition. device is the special file corresponding to the
24 device (e.g /dev/hdXX). blocks-count is the number of blocks on the
25 device. If omitted, mke2fs automagically figures the file system size.
26 If called as mkfs.ext3 a journal is created as if the -j option was
27 specified.
28
29 The defaults of the parameters for the newly created filesystem, if not
30 overridden by the options listed below, are controlled by the
31 /etc/mke2fs.conf configuration file. See the mke2fs.conf(5) manual
32 page for more details.
33
35 -b block-size
36 Specify the size of blocks in bytes. Valid block-size values
37 are 1024, 2048 and 4096 bytes per block. If omitted, block-size
38 is heuristically determined by the filesystem size and the
39 expected usage of the filesystem (see the -T option). If block-
40 size is negative, then mke2fs will use heuristics to determine
41 the appropriate block size, with the constraint that the block
42 size will be at least block-size bytes. This is useful for cer‐
43 tain hardware devices which require that the blocksize be a mul‐
44 tiple of 2k.
45
46 -c Check the device for bad blocks before creating the file system.
47 If this option is specified twice, then a slower read-write test
48 is used instead of a fast read-only test.
49
50 -E extended-options
51 Set extended options for the filesystem. Extended options are
52 comma separated, and may take an argument using the equals ('=')
53 sign. The -E option used to be -R in earlier versions of
54 mke2fs. The -R option is still accepted for backwards compati‐
55 bility. The following extended options are supported:
56
57 stride=stride-size
58 Configure the filesystem for a RAID array with
59 stride-size filesystem blocks. This is the number of
60 blocks read or written to disk before moving to the
61 next disk, which is sometimes referred to as the
62 chunk size. This mostly affects placement of
63 filesystem metadata like bitmaps at mke2fs time to
64 avoid placing them on a single disk, which can hurt
65 performance. It may also be used by the block allo‐
66 cator.
67
68 stripe-width=stripe-width
69 Configure the filesystem for a RAID array with
70 stripe-width filesystem blocks per stripe. This is
71 typically stride-size * N, where N is the number of
72 data-bearing disks in the RAID (e.g. for RAID 5
73 there is one parity disk, so N will be the number of
74 disks in the array minus 1). This allows the block
75 allocator to prevent read-modify-write of the parity
76 in a RAID stripe if possible when the data is writ‐
77 ten.
78
79 resize=max-online-resize
80 Reserve enough space so that the block group
81 descriptor table can grow to support a filesystem
82 that has max-online-resize blocks.
83
84 lazy_itable_init[= <0 to disable, 1 to enable>]
85 If enabled and the uninit_bg feature is enabled, the
86 inode table will not be fully initialized by mke2fs.
87 This speeds up filesystem initialization noticeably,
88 but it requires the kernel to finish initializing
89 the filesystem in the background when the filesystem
90 is first mounted. If the option value is omitted,
91 it defaults to 1 to enable lazy inode table initial‐
92 ization.
93
94 test_fs
95 Set a flag in the filesystem superblock indicating
96 that it may be mounted using experimental kernel
97 code, such as the ext4dev filesystem.
98
99 discard
100 Attempt to discard blocks at mkfs time (discarding
101 blocks initially is useful on solid state devices
102 and sparse / thin-provisioned storage). When the
103 device advertises that discard also zeroes data (any
104 subsequent read after the discard and before write
105 returns zero), then mark all not-yet-zeroed inode
106 tables as zeroed. This significantly speeds up
107 filesystem initialization. This is set as default.
108
109 nodiscard
110 Do not attempt to discard blocks at mkfs time.
111
112 -f fragment-size
113 Specify the size of fragments in bytes.
114
115 -F Force mke2fs to create a filesystem, even if the specified
116 device is not a partition on a block special device, or if other
117 parameters do not make sense. In order to force mke2fs to cre‐
118 ate a filesystem even if the filesystem appears to be in use or
119 is mounted (a truly dangerous thing to do), this option must be
120 specified twice.
121
122 -g blocks-per-group
123 Specify the number of blocks in a block group. There is gener‐
124 ally no reason for the user to ever set this parameter, as the
125 default is optimal for the filesystem. (For administrators who
126 are creating filesystems on RAID arrays, it is preferable to use
127 the stride RAID parameter as part of the -E option rather than
128 manipulating the number of blocks per group.) This option is
129 generally used by developers who are developing test cases.
130
131 -G number-of-groups
132 Specify the number of block groups that will be packed together
133 to create a larger virtual block group (or "flex_bg group") in
134 an ext4 filesystem. This improves meta-data locality and per‐
135 formance on meta-data heavy workloads. The number of groups
136 must be a power of 2 and may only be specified if the flex_bg
137 filesystem feature is enabled.
138
139 -i bytes-per-inode
140 Specify the bytes/inode ratio. mke2fs creates an inode for
141 every bytes-per-inode bytes of space on the disk. The larger
142 the bytes-per-inode ratio, the fewer inodes will be created.
143 This value generally shouldn't be smaller than the blocksize of
144 the filesystem, since in that case more inodes would be made
145 than can ever be used. Be warned that it is not possible to
146 expand the number of inodes on a filesystem after it is created,
147 so be careful deciding the correct value for this parameter.
148
149 -I inode-size
150 Specify the size of each inode in bytes. mke2fs creates
151 256-byte inodes by default. In kernels after 2.6.10 and some
152 earlier vendor kernels it is possible to utilize inodes larger
153 than 128 bytes to store extended attributes for improved perfor‐
154 mance. The inode-size value must be a power of 2 larger or
155 equal to 128. The larger the inode-size the more space the
156 inode table will consume, and this reduces the usable space in
157 the filesystem and can also negatively impact performance.
158 Extended attributes stored in large inodes are not visible with
159 older kernels, and such filesystems will not be mountable with
160 2.4 kernels at all. It is not possible to change this value
161 after the filesystem is created.
162
163 -j Create the filesystem with an ext3 journal. If the -J option is
164 not specified, the default journal parameters will be used to
165 create an appropriately sized journal (given the size of the
166 filesystem) stored within the filesystem. Note that you must be
167 using a kernel which has ext3 support in order to actually make
168 use of the journal.
169
170 -J journal-options
171 Create the ext3 journal using options specified on the command-
172 line. Journal options are comma separated, and may take an
173 argument using the equals ('=') sign. The following journal
174 options are supported:
175
176 size=journal-size
177 Create an internal journal (i.e., stored inside the
178 filesystem) of size journal-size megabytes. The
179 size of the journal must be at least 1024 filesystem
180 blocks (i.e., 1MB if using 1k blocks, 4MB if using
181 4k blocks, etc.) and may be no more than 102,400
182 filesystem blocks.
183
184 device=external-journal
185 Attach the filesystem to the journal block device
186 located on external-journal. The external journal
187 must already have been created using the command
188
189 mke2fs -O journal_dev external-journal
190
191 Note that external-journal must have been created
192 with the same block size as the new filesystem. In
193 addition, while there is support for attaching mul‐
194 tiple filesystems to a single external journal, the
195 Linux kernel and e2fsck(8) do not currently support
196 shared external journals yet.
197
198 Instead of specifying a device name directly, exter‐
199 nal-journal can also be specified by either
200 LABEL=label or UUID=UUID to locate the external
201 journal by either the volume label or UUID stored in
202 the ext2 superblock at the start of the journal.
203 Use dumpe2fs(8) to display a journal device's volume
204 label and UUID. See also the -L option of
205 tune2fs(8).
206
207 Only one of the size or device options can be given for a
208 filesystem.
209
210 -K Keep, do not attempt to discard blocks at mkfs time (discarding
211 blocks initially is useful on solid state devices and sparse /
212 thin-provisioned storage).
213
214 -l filename
215 Read the bad blocks list from filename. Note that the block
216 numbers in the bad block list must be generated using the same
217 block size as used by mke2fs. As a result, the -c option to
218 mke2fs is a much simpler and less error-prone method of checking
219 a disk for bad blocks before formatting it, as mke2fs will auto‐
220 matically pass the correct parameters to the badblocks program.
221
222 -L new-volume-label
223 Set the volume label for the filesystem to new-volume-label.
224 The maximum length of the volume label is 16 bytes.
225
226 -m reserved-blocks-percentage
227 Specify the percentage of the filesystem blocks reserved for the
228 super-user. This avoids fragmentation, and allows root-owned
229 daemons, such as syslogd(8), to continue to function correctly
230 after non-privileged processes are prevented from writing to the
231 filesystem. The default percentage is 5%.
232
233 -M last-mounted-directory
234 Set the last mounted directory for the filesystem. This might
235 be useful for the sake of utilities that key off of the last
236 mounted directory to determine where the filesystem should be
237 mounted.
238
239 -n Causes mke2fs to not actually create a filesystem, but display
240 what it would do if it were to create a filesystem. This can be
241 used to determine the location of the backup superblocks for a
242 particular filesystem, so long as the mke2fs parameters that
243 were passed when the filesystem was originally created are used
244 again. (With the -n option added, of course!)
245
246 -N number-of-inodes
247 Overrides the default calculation of the number of inodes that
248 should be reserved for the filesystem (which is based on the
249 number of blocks and the bytes-per-inode ratio). This allows
250 the user to specify the number of desired inodes directly.
251
252 -o creator-os
253 Overrides the default value of the "creator operating system"
254 field of the filesystem. The creator field is set by default to
255 the name of the OS the mke2fs executable was compiled for.
256
257 -O feature[,...]
258 Create a filesystem with the given features (filesystem
259 options), overriding the default filesystem options. The fea‐
260 tures that are enabled by default are specified by the base_fea‐
261 tures relation, either in the [defaults] section in the
262 /etc/mke2fs.conf configuration file, or in the [fs_types] sub‐
263 sections for the usage types as specified by the -T option, fur‐
264 ther modified by the features relation found in the [fs_types]
265 subsections for the filesystem and usage types. See the
266 mke2fs.conf(5) manual page for more details. The filesystem
267 type-specific configuration setting found in the [fs_types] sec‐
268 tion will override the global default found in [defaults].
269
270 The filesystem feature set will be further edited using either
271 the feature set specified by this option, or if this option is
272 not given, by the default_features relation for the filesystem
273 type being created, or in the [defaults] section of the configu‐
274 ration file.
275
276 The filesystem feature set is comprised of a list of features,
277 separated by commas, that are to be enabled. To disable a fea‐
278 ture, simply prefix the feature name with a caret ('^') charac‐
279 ter. The pseudo-filesystem feature "none" will clear all
280 filesystem features.
281
282 dir_index
283 Use hashed b-trees to speed up lookups in large
284 directories.
285
286 extent Instead of using the indirect block scheme for stor‐
287 ing the location of data blocks in an inode, use
288 extents instead. This is a much more efficient
289 encoding which speeds up filesystem access, espe‐
290 cially for large files.
291
292 filetype
293 Store file type information in directory entries.
294
295 flex_bg
296 Allow the per-block group metadata (allocation bit‐
297 maps and inode tables) to be placed anywhere on the
298 storage media. In addition, mke2fs will place the
299 per-block group metadata together starting at the
300 first block group of each "flex_bg group". The
301 size of the flex_bg group can be specified using the
302 -G option.
303
304 has_journal
305 Create an ext3 journal (as if using the -j option).
306
307 journal_dev
308 Create an external ext3 journal on the given device
309 instead of a regular ext2 filesystem. Note that
310 external-journal must be created with the same block
311 size as the filesystems that will be using it.
312
313 large_file
314 Filesystem can contain files that are greater than
315 2GB. (Modern kernels set this feature automatically
316 when a file > 2GB is created.)
317
318 resize_inode
319 Reserve space so the block group descriptor table
320 may grow in the future. Useful for online resizing
321 using resize2fs. By default mke2fs will attempt to
322 reserve enough space so that the filesystem may grow
323 to 1024 times its initial size. This can be changed
324 using the resize extended option.
325
326 sparse_super
327 Create a filesystem with fewer superblock backup
328 copies (saves space on large filesystems).
329
330 uninit_bg
331 Create a filesystem without initializing all of the
332 block groups. This feature also enables checksums
333 and highest-inode-used statistics in each block‐
334 group. This feature can speed up filesystem cre‐
335 ation time noticeably (if lazy_itable_init is
336 enabled), and can also reduce e2fsck time dramati‐
337 cally. It is only supported by the ext4 filesystem
338 in recent Linux kernels.
339
340 -q Quiet execution. Useful if mke2fs is run in a script.
341
342 -r revision
343 Set the filesystem revision for the new filesystem. Note that
344 1.2 kernels only support revision 0 filesystems. The default is
345 to create revision 1 filesystems.
346
347 -S Write superblock and group descriptors only. This is useful if
348 all of the superblock and backup superblocks are corrupted, and
349 a last-ditch recovery method is desired. It causes mke2fs to
350 reinitialize the superblock and group descriptors, while not
351 touching the inode table and the block and inode bitmaps. The
352 e2fsck program should be run immediately after this option is
353 used, and there is no guarantee that any data will be salvage‐
354 able. It is critical to specify the correct filesystem block‐
355 size when using this option, or there is no chance of recovery.
356
357 -t fs-type
358 Specify the filesystem type (i.e., ext2, ext3, ext4, etc.) that
359 is to be created. If this option is not specified, mke2fs will
360 pick a default either via how the command was run (for example,
361 using a name of the form mkfs.ext2, mkfs.ext3, etc.) or via a
362 default as defined by the /etc/mke2fs.conf(5) file. This
363 option controls which filesystem options are used by default,
364 based on the fstypes configuration stanza in
365 /etc/mke2fs.conf(5).
366
367 If the -O option is used to explicitly add or remove filesystem
368 options that should be set in the newly created filesystem, the
369 resulting filesystem may not be supported by the requested fs-
370 type. (e.g., "mke2fs -t ext3 -O extents /dev/sdXX" will create
371 a filesystem that is not supported by the ext3 implementation as
372 found in the Linux kernel; and "mke2fs -t ext3 -O ^has_journal
373 /dev/hdXX" will create a filesystem that does not have a journal
374 and hence will not be supported by the ext3 filesystem code in
375 the Linux kernel.)
376
377 -T usage-type[,...]
378 Specify how the filesystem is going to be used, so that mke2fs
379 can choose optimal filesystem parameters for that use. The
380 usage types that are supported are defined in the configuration
381 file /etc/mke2fs.conf(5). The user may specify one or more
382 usage types using a comma separated list.
383
384 If this option is is not specified, mke2fs will pick a single
385 default usage type based on the size of the filesystem to be
386 created. If the filesystem size is less than or equal to 3
387 megabytes, mke2fs will use the filesystem type floppy. If the
388 filesystem size is greater than 3 but less than or equal to 512
389 megabytes, mke2fs(8) will use the filesystem small. Otherwise,
390 mke2fs(8) will use the default filesystem type default.
391
392 -U UUID
393 Create the filesystem with the specified UUID.
394
395 -v Verbose execution.
396
397 -V Print the version number of mke2fs and exit.
398
400 This version of mke2fs has been written by Theodore Ts'o
401 <tytso@mit.edu>.
402
404 mke2fs accepts the -f option but currently ignores it because the sec‐
405 ond extended file system does not support fragments yet.
406 There may be other ones. Please, report them to the author.
407
409 mke2fs is part of the e2fsprogs package and is available from
410 http://e2fsprogs.sourceforge.net.
411
413 mke2fs.conf(5), badblocks(8), dumpe2fs(8), e2fsck(8), tune2fs(8)
414
415
416
417E2fsprogs version 1.41.12 May 2010 MKE2FS(8)