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

ENVIRONMENT

399       MKE2FS_SYNC
400              If set to non-zero integer value, its value is used to determine
401              how often sync(2) is called during inode table initialization.
402
403       MKE2FS_CONFIG
404              Determines  the  location  of  the   configuration   file   (see
405              mke2fs.conf(5)).
406
407       MKE2FS_FIRST_META_BG
408              If set to non-zero integer value, its value is used to determine
409              first meta block group. This is mostly for debugging purposes.
410
411       MKE2FS_DEVICE_SECTSIZE
412              If set to non-zero integer value, its value is used to determine
413              physical sector size of the device.
414
415       MKE2FS_SKIP_CHECK_MSG
416              If  set,  do  not show the message of filesystem automatic check
417              caused by mount count or check interval.
418

AUTHOR

420       This  version  of  mke2fs   has   been   written   by   Theodore   Ts'o
421       <tytso@mit.edu>.
422

BUGS

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

AVAILABILITY

429       mke2fs  is  part  of  the  e2fsprogs  package  and  is  available  from
430       http://e2fsprogs.sourceforge.net.
431

SEE ALSO

433       mke2fs.conf(5),   badblocks(8),   dumpe2fs(8),  e2fsck(8),  tune2fs(8),
434       ext4(5)
435
436
437
438E2fsprogs version 1.42.9         December 2013                       MKE2FS(8)
Impressum