1MKE2FS(8)                   System Manager's Manual                  MKE2FS(8)
2
3
4

NAME

6       mke2fs - create an ext2/ext3/ext4 filesystem
7

SYNOPSIS

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

DESCRIPTION

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

OPTIONS

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       -f fragment-size
100              Specify the size of fragments in bytes.
101
102       -F     Force mke2fs to create  a  filesystem,  even  if  the  specified
103              device is not a partition on a block special device, or if other
104              parameters do not make sense.  In order to force mke2fs to  cre‐
105              ate  a filesystem even if the filesystem appears to be in use or
106              is mounted (a truly dangerous thing to do), this option must  be
107              specified twice.
108
109       -g blocks-per-group
110              Specify  the number of blocks in a block group.  There is gener‐
111              ally no reason for the user to ever set this parameter,  as  the
112              default  is optimal for the filesystem.  (For administrators who
113              are creating filesystems on RAID arrays, it is preferable to use
114              the  stride  RAID parameter as part of the -E option rather than
115              manipulating the number of blocks per group.)   This  option  is
116              generally used by developers who are developing test cases.
117
118       -G number-of-groups
119              Specify  the number of block groups that will be packed together
120              to create a larger virtual block group (or "flex_bg  group")  in
121              an  ext4  filesystem.  This improves meta-data locality and per‐
122              formance on meta-data heavy workloads.   The  number  of  groups
123              must  be  a  power of 2 and may only be specified if the flex_bg
124              filesystem feature is enabled.
125
126       -i bytes-per-inode
127              Specify the bytes/inode ratio.   mke2fs  creates  an  inode  for
128              every  bytes-per-inode  bytes  of space on the disk.  The larger
129              the bytes-per-inode ratio, the fewer  inodes  will  be  created.
130              This  value generally shouldn't be smaller than the blocksize of
131              the filesystem, since in that case more  inodes  would  be  made
132              than  can  ever  be  used.  Be warned that it is not possible to
133              expand the number of inodes on a filesystem after it is created,
134              so be careful deciding the correct value for this parameter.
135
136       -I inode-size
137              Specify  the  size  of  each  inode  in  bytes.   mke2fs creates
138              256-byte inodes by default.  In kernels after  2.6.10  and  some
139              earlier  vendor  kernels it is possible to utilize inodes larger
140              than 128 bytes to store extended attributes for improved perfor‐
141              mance.   The  inode-size  value  must  be a power of 2 larger or
142              equal to 128.  The larger the  inode-size  the  more  space  the
143              inode  table  will consume, and this reduces the usable space in
144              the filesystem  and  can  also  negatively  impact  performance.
145              Extended  attributes stored in large inodes are not visible with
146              older kernels, and such filesystems will not be  mountable  with
147              2.4  kernels  at  all.   It is not possible to change this value
148              after the filesystem is created.
149
150       -j     Create the filesystem with an ext3 journal.  If the -J option is
151              not  specified,  the  default journal parameters will be used to
152              create an appropriately sized journal (given  the  size  of  the
153              filesystem) stored within the filesystem.  Note that you must be
154              using a kernel which has ext3 support in order to actually  make
155              use of the journal.
156
157       -J journal-options
158              Create  the ext3 journal using options specified on the command-
159              line.  Journal options are comma  separated,  and  may  take  an
160              argument  using  the  equals ('=')  sign.  The following journal
161              options are supported:
162
163                   size=journal-size
164                          Create an internal journal (i.e., stored inside  the
165                          filesystem)  of  size  journal-size  megabytes.  The
166                          size of the journal must be at least 1024 filesystem
167                          blocks  (i.e.,  1MB if using 1k blocks, 4MB if using
168                          4k blocks, etc.)  and may be no  more  than  102,400
169                          filesystem blocks.
170
171                   device=external-journal
172                          Attach  the  filesystem  to the journal block device
173                          located on external-journal.  The  external  journal
174                          must already have been created using the command
175
176                          mke2fs -O journal_dev external-journal
177
178                          Note  that  external-journal  must have been created
179                          with the same block size as the new filesystem.   In
180                          addition,  while there is support for attaching mul‐
181                          tiple filesystems to a single external journal,  the
182                          Linux  kernel and e2fsck(8) do not currently support
183                          shared external journals yet.
184
185                          Instead of specifying a device name directly, exter‐
186                          nal-journal   can   also   be  specified  by  either
187                          LABEL=label or  UUID=UUID  to  locate  the  external
188                          journal by either the volume label or UUID stored in
189                          the ext2 superblock at the  start  of  the  journal.
190                          Use dumpe2fs(8) to display a journal device's volume
191                          label  and  UUID.   See  also  the  -L   option   of
192                          tune2fs(8).
193
194              Only  one  of  the  size  or  device  options can be given for a
195              filesystem.
196
197       -K     Keep, do not attempt to discard blocks at mkfs time  (discarding
198              blocks  initially  is useful on solid state devices and sparse /
199              thin-provisioned storage).
200
201       -l filename
202              Read the bad blocks list from filename.   Note  that  the  block
203              numbers  in  the bad block list must be generated using the same
204              block size as used by mke2fs.  As a result,  the  -c  option  to
205              mke2fs is a much simpler and less error-prone method of checking
206              a disk for bad blocks before formatting it, as mke2fs will auto‐
207              matically pass the correct parameters to the badblocks program.
208
209       -L new-volume-label
210              Set  the  volume  label  for the filesystem to new-volume-label.
211              The maximum length of the volume label is 16 bytes.
212
213       -m reserved-blocks-percentage
214              Specify the percentage of the filesystem blocks reserved for the
215              super-user.   This  avoids  fragmentation, and allows root-owned
216              daemons, such as syslogd(8), to continue to  function  correctly
217              after non-privileged processes are prevented from writing to the
218              filesystem.  The default percentage is 5%.
219
220       -M last-mounted-directory
221              Set the last mounted directory for the filesystem.   This  might
222              be  useful  for  the  sake of utilities that key off of the last
223              mounted directory to determine where the  filesystem  should  be
224              mounted.
225
226       -n     Causes  mke2fs  to not actually create a filesystem, but display
227              what it would do if it were to create a filesystem.  This can be
228              used  to  determine the location of the backup superblocks for a
229              particular filesystem, so long as  the  mke2fs  parameters  that
230              were  passed when the filesystem was originally created are used
231              again.  (With the -n option added, of course!)
232
233       -N number-of-inodes
234              Overrides the default calculation of the number of  inodes  that
235              should  be  reserved  for  the filesystem (which is based on the
236              number of blocks and the bytes-per-inode  ratio).   This  allows
237              the user to specify the number of desired inodes directly.
238
239       -o creator-os
240              Overrides  the  default  value of the "creator operating system"
241              field of the filesystem.  The creator field is set by default to
242              the name of the OS the mke2fs executable was compiled for.
243
244       -O feature[,...]
245              Create   a   filesystem  with  the  given  features  (filesystem
246              options), overriding the default filesystem options.   The  fea‐
247              tures that are enabled by default are specified by the base_fea‐
248              tures  relation,  either  in  the  [defaults]  section  in   the
249              /etc/mke2fs.conf  configuration  file, or in the [fs_types] sub‐
250              sections for the usage types as specified by the -T option, fur‐
251              ther  modified  by the features relation found in the [fs_types]
252              subsections  for  the  filesystem  and  usage  types.   See  the
253              mke2fs.conf(5)  manual  page  for  more details.  The filesystem
254              type-specific configuration setting found in the [fs_types] sec‐
255              tion will override the global default found in [defaults].
256
257              The  filesystem  feature set will be further edited using either
258              the feature set specified by this option, or if this  option  is
259              not  given,  by the default_features relation for the filesystem
260              type being created, or in the [defaults] section of the configu‐
261              ration file.
262
263              The  filesystem  feature set is comprised of a list of features,
264              separated by commas, that are to be enabled.  To disable a  fea‐
265              ture, simply prefix the feature name with a  caret ('^') charac‐
266              ter.   The  pseudo-filesystem  feature  "none"  will  clear  all
267              filesystem features.
268
269                   dir_index
270                          Use  hashed  b-trees  to  speed  up lookups in large
271                          directories.
272
273                   extent Instead of using the indirect block scheme for stor‐
274                          ing  the  location  of  data blocks in an inode, use
275                          extents instead.  This  is  a  much  more  efficient
276                          encoding  which  speeds  up filesystem access, espe‐
277                          cially for large files.
278
279                   filetype
280                          Store file type information in directory entries.
281
282                   flex_bg
283                          Allow the per-block group metadata (allocation  bit‐
284                          maps  and inode tables) to be placed anywhere on the
285                          storage media.  In addition, mke2fs will  place  the
286                          per-block  group  metadata  together starting at the
287                          first block group of  each  "flex_bg  group".    The
288                          size of the flex_bg group can be specified using the
289                          -G option.
290
291                   has_journal
292                          Create an ext3 journal (as if using the -j option).
293
294                   journal_dev
295                          Create an external ext3 journal on the given  device
296                          instead  of  a  regular  ext2 filesystem.  Note that
297                          external-journal must be created with the same block
298                          size as the filesystems that will be using it.
299
300                   large_file
301                          Filesystem  can  contain files that are greater than
302                          2GB.  (Modern kernels set this feature automatically
303                          when a file > 2GB is created.)
304
305                   resize_inode
306                          Reserve  space  so  the block group descriptor table
307                          may grow in the future.  Useful for online  resizing
308                          using  resize2fs.  By default mke2fs will attempt to
309                          reserve enough space so that the filesystem may grow
310                          to 1024 times its initial size.  This can be changed
311                          using the resize extended option.
312
313                   sparse_super
314                          Create a filesystem  with  fewer  superblock  backup
315                          copies (saves space on large filesystems).
316
317                   uninit_bg
318                          Create  a filesystem without initializing all of the
319                          block groups.  This feature also  enables  checksums
320                          and  highest-inode-used  statistics  in  each block‐
321                          group.  This feature can speed  up  filesystem  cre‐
322                          ation   time   noticeably  (if  lazy_itable_init  is
323                          enabled), and can also reduce e2fsck  time  dramati‐
324                          cally.   It is only supported by the ext4 filesystem
325                          in recent Linux kernels.
326
327       -q     Quiet execution.  Useful if mke2fs is run in a script.
328
329       -r revision
330              Set the filesystem revision for the new filesystem.   Note  that
331              1.2 kernels only support revision 0 filesystems.  The default is
332              to create revision 1 filesystems.
333
334       -S     Write superblock and group descriptors only.  This is useful  if
335              all  of the superblock and backup superblocks are corrupted, and
336              a last-ditch recovery method is desired.  It  causes  mke2fs  to
337              reinitialize  the  superblock  and  group descriptors, while not
338              touching the inode table and the block and inode  bitmaps.   The
339              e2fsck  program  should  be run immediately after this option is
340              used, and there is no guarantee that any data will  be  salvage‐
341              able.   It  is critical to specify the correct filesystem block‐
342              size when using this option, or there is no chance of recovery.
343
344       -t fs-type
345              Specify the filesystem type (i.e., ext2, ext3, ext4, etc.)  that
346              is  to be created.  If this option is not specified, mke2fs will
347              pick a default either via how the command was run (for  example,
348              using  a  name  of the form mkfs.ext2, mkfs.ext3, etc.) or via a
349              default as  defined  by  the  /etc/mke2fs.conf(5)  file.    This
350              option  controls  which  filesystem options are used by default,
351              based    on    the    fstypes    configuration     stanza     in
352              /etc/mke2fs.conf(5).
353
354              If  the -O option is used to explicitly add or remove filesystem
355              options that should be set in the newly created filesystem,  the
356              resulting  filesystem  may not be supported by the requested fs-
357              type.  (e.g., "mke2fs -t ext3 -O extents /dev/sdXX" will  create
358              a filesystem that is not supported by the ext3 implementation as
359              found in the Linux kernel; and "mke2fs -t ext3  -O  ^has_journal
360              /dev/hdXX" will create a filesystem that does not have a journal
361              and hence will not be supported by the ext3 filesystem  code  in
362              the Linux kernel.)
363
364       -T usage-type[,...]
365              Specify  how  the filesystem is going to be used, so that mke2fs
366              can choose optimal filesystem  parameters  for  that  use.   The
367              usage  types that are supported are defined in the configuration
368              file /etc/mke2fs.conf(5).  The user  may  specify  one  or  more
369              usage types using a comma separated list.
370
371              If  this  option  is is not specified, mke2fs will pick a single
372              default usage type based on the size of  the  filesystem  to  be
373              created.   If  the  filesystem  size  is less than or equal to 3
374              megabytes, mke2fs will use the filesystem type floppy.   If  the
375              filesystem  size is greater than 3 but less than or equal to 512
376              megabytes, mke2fs(8) will use the filesystem small.   Otherwise,
377              mke2fs(8) will use the default filesystem type default.
378
379       -U UUID
380              Create the filesystem with the specified UUID.
381
382       -v     Verbose execution.
383
384       -V     Print the version number of mke2fs and exit.
385

AUTHOR

387       This   version   of   mke2fs   has   been   written  by  Theodore  Ts'o
388       <tytso@mit.edu>.
389

BUGS

391       mke2fs accepts the -f option but currently ignores it because the  sec‐
392       ond extended file system does not support fragments yet.
393       There may be other ones.  Please, report them to the author.
394

AVAILABILITY

396       mke2fs  is  part  of  the  e2fsprogs  package  and  is  available  from
397       http://e2fsprogs.sourceforge.net.
398

SEE ALSO

400       mke2fs.conf(5), badblocks(8), dumpe2fs(8), e2fsck(8), tune2fs(8)
401
402
403
404E2fsprogs version 1.41.12          May 2010                          MKE2FS(8)
Impressum