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 ] [ -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

DESCRIPTION

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

OPTIONS

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                   mmp_update_interval=interval
99                          Adjust  the  initial MMP update interval to interval
100                          seconds.  Specifying an interval of 0 means  to  use
101                          the  default  interval.  The specified interval must
102                          be less than 300 seconds.   Requires  that  the  mmp
103                          feature be enabled.
104
105                   stride=stride-size
106                          Configure  the  filesystem  for  a  RAID  array with
107                          stride-size filesystem blocks. This is the number of
108                          blocks  read or written to disk before moving to the
109                          next disk, which is sometimes  referred  to  as  the
110                          chunk   size.   This  mostly  affects  placement  of
111                          filesystem metadata like bitmaps at mke2fs  time  to
112                          avoid  placing them on a single disk, which can hurt
113                          performance.  It may also be used by the block allo‐
114                          cator.
115
116                   stripe_width=stripe-width
117                          Configure  the  filesystem  for  a  RAID  array with
118                          stripe-width filesystem blocks per stripe.  This  is
119                          typically  stride-size * N, where N is the number of
120                          data-bearing disks in the  RAID  (e.g.  for  RAID  5
121                          there is one parity disk, so N will be the number of
122                          disks in the array minus 1).  This allows the  block
123                          allocator to prevent read-modify-write of the parity
124                          in a RAID stripe if possible when the data is  writ‐
125                          ten.
126
127                   offset=offset
128                          Create  the  filesystem at an offset from the begin‐
129                          ning of the device or file.  This can be useful when
130                          creating disk images for virtual machines.
131
132                   resize=max-online-resize
133                          Reserve   enough  space  so  that  the  block  group
134                          descriptor table can grow to  support  a  filesystem
135                          that has max-online-resize blocks.
136
137                   lazy_itable_init[= <0 to disable, 1 to enable>]
138                          If enabled and the uninit_bg feature is enabled, the
139                          inode table will not be fully initialized by mke2fs.
140                          This speeds up filesystem initialization noticeably,
141                          but it requires the kernel  to  finish  initializing
142                          the filesystem in the background when the filesystem
143                          is first mounted.  If the option value  is  omitted,
144                          it defaults to 1 to enable lazy inode table zeroing.
145
146                   lazy_journal_init[= <0 to disable, 1 to enable>]
147                          If  enabled,  the  journal  inode  will not be fully
148                          zeroed out by mke2fs.   This  speeds  up  filesystem
149                          initialization  noticeably,  but  carries some small
150                          risk if the system crashes before  the  journal  has
151                          been  overwritten  entirely one time.  If the option
152                          value is omitted, it defaults to 1  to  enable  lazy
153                          journal inode zeroing.
154
155                   no_copy_xattrs
156                          Normally mke2fs will copy the extended attributes of
157                          the files in the directory hierarchy  specified  via
158                          the  (optional)  -d  option.   This will disable the
159                          copy and leaves the files in the newly created  file
160                          system without any extended attributes.
161
162                   num_backup_sb=<0|1|2>
163                          If  the sparse_super2 file system feature is enabled
164                          this option controls whether there will be 0, 1,  or
165                          2 backup superblocks created in the file system.
166
167                   packed_meta_blocks[= <0 to disable, 1 to enable>]
168                          Place  the allocation bitmaps and the inode table at
169                          the beginning of the  disk.   This  option  requires
170                          that  the  flex_bg file system feature to be enabled
171                          in order for it to have effect, and will also create
172                          the  journal  at  the  beginning of the file system.
173                          This option is useful for flash devices that use SLC
174                          flash  at  the beginning of the disk.  It also maxi‐
175                          mizes the range of contiguous data blocks, which can
176                          be useful for certain specialized use cases, such as
177                          supported Shingled Drives.
178
179                   root_owner[=uid:gid]
180                          Specify the numeric user and group ID  of  the  root
181                          directory.  If no UID:GID is specified, use the user
182                          and group ID of the user running mke2fs.  In  mke2fs
183                          1.42  and earlier the UID and GID of the root direc‐
184                          tory were set by default to the UID and GID  of  the
185                          user  running  the  mke2fs command.  The root_owner=
186                          option allows explicitly  specifying  these  values,
187                          and  avoid side-effects for users that do not expect
188                          the contents of the filesystem to  change  based  on
189                          the user running mke2fs.
190
191                   test_fs
192                          Set  a  flag in the filesystem superblock indicating
193                          that it may be  mounted  using  experimental  kernel
194                          code, such as the ext4dev filesystem.
195
196                   discard
197                          Attempt  to  discard blocks at mkfs time (discarding
198                          blocks initially is useful on  solid  state  devices
199                          and  sparse  /  thin-provisioned  storage). When the
200                          device advertises that discard also zeroes data (any
201                          subsequent  read  after the discard and before write
202                          returns zero), then mark  all  not-yet-zeroed  inode
203                          tables  as  zeroed.  This  significantly  speeds  up
204                          filesystem initialization. This is set as default.
205
206                   nodiscard
207                          Do not attempt to discard blocks at mkfs time.
208
209                   quotatype
210                          Specify the which  quota types (usrquota,  grpquota,
211                          prjquota)  which  should  be  enabled in the created
212                          file system.  The argument of this  extended  option
213                          should  be  a colon separated list.  This option has
214                          effect only if  the  quota  feature  is  set.    The
215                          default quota types to be initialized if this option
216                          is not specified is both user and group quotas.   If
217                          the  project  feature is enabled that project quotas
218                          will be initialized as well.
219
220       -F     Force mke2fs to create  a  filesystem,  even  if  the  specified
221              device is not a partition on a block special device, or if other
222              parameters do not make sense.  In order to force mke2fs to  cre‐
223              ate  a filesystem even if the filesystem appears to be in use or
224              is mounted (a truly dangerous thing to do), this option must  be
225              specified twice.
226
227       -g blocks-per-group
228              Specify  the number of blocks in a block group.  There is gener‐
229              ally no reason for the user to ever set this parameter,  as  the
230              default  is optimal for the filesystem.  (For administrators who
231              are creating filesystems on RAID arrays, it is preferable to use
232              the  stride  RAID parameter as part of the -E option rather than
233              manipulating the number of blocks per group.)   This  option  is
234              generally used by developers who are developing test cases.
235
236              If  the  bigalloc feature is enabled, the -g option will specify
237              the number of clusters in a block group.
238
239       -G number-of-groups
240              Specify the number of block groups that will be packed  together
241              to  create  a larger virtual block group (or "flex_bg group") in
242              an ext4 filesystem.  This improves meta-data locality  and  per‐
243              formance  on  meta-data  heavy  workloads.  The number of groups
244              must be a power of 2 and may only be specified  if  the  flex_bg
245              filesystem feature is enabled.
246
247       -i bytes-per-inode
248              Specify  the  bytes/inode  ratio.   mke2fs  creates an inode for
249              every bytes-per-inode bytes of space on the  disk.   The  larger
250              the  bytes-per-inode  ratio,  the  fewer inodes will be created.
251              This value generally shouldn't be smaller than the blocksize  of
252              the  filesystem,  since  in  that case more inodes would be made
253              than can ever be used.  Be warned that it  is  not  possible  to
254              change  this  ratio  on  a filesystem after it is created, so be
255              careful deciding the correct value  for  this  parameter.   Note
256              that resizing a filesystem changes the number of inodes to main‐
257              tain this ratio.
258
259       -I inode-size
260              Specify the size of each inode in bytes.  The  inode-size  value
261              must  be  a  power  of 2 larger or equal to 128.  The larger the
262              inode-size the more space the inode table will consume, and this
263              reduces  the  usable  space in the filesystem and can also nega‐
264              tively impact performance.  It is not possible  to  change  this
265              value after the filesystem is created.
266
267              In  kernels  after  2.6.10 and some earlier vendor kernels it is
268              possible to utilize  inodes  larger  than  128  bytes  to  store
269              extended   attributes   for   improved   performance.   Extended
270              attributes stored in large inodes are  not  visible  with  older
271              kernels,  and  such  filesystems  will not be mountable with 2.4
272              kernels at all.
273
274              The default inode size is controlled by the mke2fs.conf(5) file.
275              In  the  mke2fs.conf  file  shipped  with e2fsprogs, the default
276              inode size is 256 bytes for most file systems, except for  small
277              file systems where the inode size will be 128 bytes.
278
279       -j     Create the filesystem with an ext3 journal.  If the -J option is
280              not specified, the default journal parameters will  be  used  to
281              create  an  appropriately  sized  journal (given the size of the
282              filesystem) stored within the filesystem.  Note that you must be
283              using  a kernel which has ext3 support in order to actually make
284              use of the journal.
285
286       -J journal-options
287              Create the ext3 journal using options specified on the  command-
288              line.   Journal  options  are  comma  separated, and may take an
289              argument using the equals ('=')  sign.   The  following  journal
290              options are supported:
291
292                   size=journal-size
293                          Create  an internal journal (i.e., stored inside the
294                          filesystem) of  size  journal-size  megabytes.   The
295                          size of the journal must be at least 1024 filesystem
296                          blocks (i.e., 1MB if using 1k blocks, 4MB  if  using
297                          4k blocks, etc.)  and may be no more than 10,240,000
298                          filesystem blocks or half the total file system size
299                          (whichever is smaller)
300
301                   location=journal-location
302                          Specify  the  location of the journal.  The argument
303                          journal-location can either be specified as a  block
304                          number,  or  if the number has a units suffix (e.g.,
305                          'M', 'G', etc.) interpret it as the offset from  the
306                          beginning of the file system.
307
308                   device=external-journal
309                          Attach  the  filesystem  to the journal block device
310                          located on external-journal.  The  external  journal
311                          must already have been created using the command
312
313                          mke2fs -O journal_dev external-journal
314
315                          Note  that  external-journal  must have been created
316                          with the same block size as the new filesystem.   In
317                          addition,  while there is support for attaching mul‐
318                          tiple filesystems to a single external journal,  the
319                          Linux  kernel and e2fsck(8) do not currently support
320                          shared external journals yet.
321
322                          Instead of specifying a device name directly, exter‐
323                          nal-journal   can   also   be  specified  by  either
324                          LABEL=label or  UUID=UUID  to  locate  the  external
325                          journal by either the volume label or UUID stored in
326                          the ext2 superblock at the  start  of  the  journal.
327                          Use dumpe2fs(8) to display a journal device's volume
328                          label  and  UUID.   See  also  the  -L   option   of
329                          tune2fs(8).
330
331              Only  one  of  the  size  or  device  options can be given for a
332              filesystem.
333
334       -l filename
335              Read the bad blocks list from filename.   Note  that  the  block
336              numbers  in  the bad block list must be generated using the same
337              block size as used by mke2fs.  As a result,  the  -c  option  to
338              mke2fs is a much simpler and less error-prone method of checking
339              a disk for bad blocks before formatting it, as mke2fs will auto‐
340              matically pass the correct parameters to the badblocks program.
341
342       -L new-volume-label
343              Set  the  volume  label  for the filesystem to new-volume-label.
344              The maximum length of the volume label is 16 bytes.
345
346       -m reserved-blocks-percentage
347              Specify the percentage of the filesystem blocks reserved for the
348              super-user.   This  avoids  fragmentation, and allows root-owned
349              daemons, such as syslogd(8), to continue to  function  correctly
350              after non-privileged processes are prevented from writing to the
351              filesystem.  The default percentage is 5%.
352
353       -M last-mounted-directory
354              Set the last mounted directory for the filesystem.   This  might
355              be  useful  for  the  sake of utilities that key off of the last
356              mounted directory to determine where the  filesystem  should  be
357              mounted.
358
359       -n     Causes  mke2fs  to not actually create a filesystem, but display
360              what it would do if it were to create a filesystem.  This can be
361              used  to  determine the location of the backup superblocks for a
362              particular filesystem, so long as  the  mke2fs  parameters  that
363              were  passed when the filesystem was originally created are used
364              again.  (With the -n option added, of course!)
365
366       -N number-of-inodes
367              Overrides the default calculation of the number of  inodes  that
368              should  be  reserved  for  the filesystem (which is based on the
369              number of blocks and the bytes-per-inode  ratio).   This  allows
370              the user to specify the number of desired inodes directly.
371
372       -o creator-os
373              Overrides  the  default  value of the "creator operating system"
374              field of the filesystem.  The creator field is set by default to
375              the name of the OS the mke2fs executable was compiled for.
376
377       -O [^]feature[,...]
378              Create   a   filesystem  with  the  given  features  (filesystem
379              options), overriding the default filesystem options.   The  fea‐
380              tures that are enabled by default are specified by the base_fea‐
381              tures  relation,  either  in  the  [defaults]  section  in   the
382              /etc/mke2fs.conf  configuration  file, or in the [fs_types] sub‐
383              sections for the usage types as specified by the -T option, fur‐
384              ther  modified  by the features relation found in the [fs_types]
385              subsections  for  the  filesystem  and  usage  types.   See  the
386              mke2fs.conf(5)  manual  page  for  more details.  The filesystem
387              type-specific configuration setting found in the [fs_types] sec‐
388              tion will override the global default found in [defaults].
389
390              The  filesystem  feature set will be further edited using either
391              the feature set specified by this option, or if this  option  is
392              not  given,  by the default_features relation for the filesystem
393              type being created, or in the [defaults] section of the configu‐
394              ration file.
395
396              The  filesystem  feature set is comprised of a list of features,
397              separated by commas, that are to be enabled.  To disable a  fea‐
398              ture,  simply prefix the feature name with a caret ('^') charac‐
399              ter.  Features with dependencies will not  be  removed  success‐
400              fully.   The  pseudo-filesystem  feature  "none"  will clear all
401              filesystem features.
402
403       For more information about the features which can be set, please see
404              the manual page ext4(5).
405
406       -q     Quiet execution.  Useful if mke2fs is run in a script.
407
408       -r revision
409              Set the filesystem revision for the new filesystem.   Note  that
410              1.2 kernels only support revision 0 filesystems.  The default is
411              to create revision 1 filesystems.
412
413       -S     Write superblock and group descriptors only.  This is an extreme
414              measure  to  be taken only in the very unlikely case that all of
415              the superblock and backup superblocks are corrupted, and a last-
416              ditch  recovery  method  is  desired  by  experienced users.  It
417              causes mke2fs to reinitialize the superblock and group  descrip‐
418              tors, while not touching the inode table and the block and inode
419              bitmaps.  The e2fsck program should  be  run  immediately  after
420              this  option  is  used,  and there is no guarantee that any data
421              will be salvageable.   Due  to  the  wide  variety  of  possible
422              options to mke2fs that affect the on-disk layout, it is critical
423              to specify exactly the same format options, such  as  blocksize,
424              fs-type,  feature  flags,  and  other  tunables  when using this
425              option, or the filesystem will be further  corrupted.   In  some
426              cases,  such  as filesystems that have been resized, or have had
427              features enabled after format time, it is  impossible  to  over‐
428              write  all  of  the  superblocks  correctly,  and  at least some
429              filesystem corruption will occur.  It is best to run this  on  a
430              full  copy  of  the  filesystem so other options can be tried if
431              this doesn't work.
432
433       -t fs-type
434              Specify the filesystem type (i.e., ext2, ext3, ext4, etc.)  that
435              is  to be created.  If this option is not specified, mke2fs will
436              pick a default either via how the command was run (for  example,
437              using  a  name  of the form mkfs.ext2, mkfs.ext3, etc.) or via a
438              default as defined by the /etc/mke2fs.conf file.    This  option
439              controls  which filesystem options are used by default, based on
440              the fstypes configuration stanza in /etc/mke2fs.conf.
441
442              If the -O option is used to explicitly add or remove  filesystem
443              options  that should be set in the newly created filesystem, the
444              resulting filesystem may not be supported by the  requested  fs-
445              type.  (e.g., "mke2fs -t ext3 -O extent /dev/sdXX" will create a
446              filesystem that is not supported by the ext3  implementation  as
447              found  in  the Linux kernel; and "mke2fs -t ext3 -O ^has_journal
448              /dev/hdXX" will create a filesystem that does not have a journal
449              and  hence  will not be supported by the ext3 filesystem code in
450              the Linux kernel.)
451
452       -T usage-type[,...]
453              Specify how the filesystem is going to be used, so  that  mke2fs
454              can  choose  optimal  filesystem  parameters  for that use.  The
455              usage types that are supported are defined in the  configuration
456              file  /etc/mke2fs.conf.   The user may specify one or more usage
457              types using a comma separated list.
458
459              If this option is is not specified, mke2fs will  pick  a  single
460              default  usage  type  based  on the size of the filesystem to be
461              created.  If the filesystem  size  is  less  than  3  megabytes,
462              mke2fs  will  use the filesystem type floppy.  If the filesystem
463              size is greater than or equal to 3 but less than 512  megabytes,
464              mke2fs(8) will use the filesystem type small.  If the filesystem
465              size is greater than or equal to 4 terabytes but  less  than  16
466              terabytes,  mke2fs(8)  will use the filesystem type big.  If the
467              filesystem size is  greater  than  or  equal  to  16  terabytes,
468              mke2fs(8)   will  use  the  filesystem  type  huge.   Otherwise,
469              mke2fs(8) will use the default filesystem type default.
470
471       -U UUID
472              Set the universally unique identifier (UUID) of  the  filesystem
473              to UUID.  The format of the UUID is a series of hex digits sepa‐
474              rated          by          hyphens,          like          this:
475              "c1b9d5a2-f162-11cf-9ece-0020afc76f16".   The UUID parameter may
476              also be one of the following:
477
478                   clear  clear the filesystem UUID
479
480                   random generate a new randomly-generated UUID
481
482                   time   generate a new time-based UUID
483
484       -v     Verbose execution.
485
486       -V     Print the version number of mke2fs and exit.
487
488       -z undo_file
489              Before overwriting a file system block, write the  old  contents
490              of  the  block to an undo file.  This undo file can be used with
491              e2undo(8) to restore the old contents of the file system  should
492              something  go  wrong.   If  the  empty  string  is passed as the
493              undo_file argument, the undo file will  be  written  to  a  file
494              named  mke2fs-device.e2undo  in  the directory specified via the
495              E2FSPROGS_UNDO_DIR environment variable or the  undo_dir  direc‐
496              tive in the configuration file.
497
498              WARNING: The undo file cannot be used to recover from a power or
499              system crash.
500

ENVIRONMENT

502       MKE2FS_SYNC
503              If set to non-zero integer value, its value is used to determine
504              how often sync(2) is called during inode table initialization.
505
506       MKE2FS_CONFIG
507              Determines   the   location   of  the  configuration  file  (see
508              mke2fs.conf(5)).
509
510       MKE2FS_FIRST_META_BG
511              If set to non-zero integer value, its value is used to determine
512              first meta block group. This is mostly for debugging purposes.
513
514       MKE2FS_DEVICE_SECTSIZE
515              If set to non-zero integer value, its value is used to determine
516              logical sector size of the device.
517
518       MKE2FS_DEVICE_PHYS_SECTSIZE
519              If set to non-zero integer value, its value is used to determine
520              physical sector size of the device.
521
522       MKE2FS_SKIP_CHECK_MSG
523              If  set,  do  not show the message of filesystem automatic check
524              caused by mount count or check interval.
525

AUTHOR

527       This  version  of  mke2fs   has   been   written   by   Theodore   Ts'o
528       <tytso@mit.edu>.
529

AVAILABILITY

531       mke2fs  is  part  of  the  e2fsprogs  package  and  is  available  from
532       http://e2fsprogs.sourceforge.net.
533

SEE ALSO

535       mke2fs.conf(5),  badblocks(8),  dumpe2fs(8),   e2fsck(8),   tune2fs(8),
536       ext4(5)
537
538
539
540E2fsprogs version 1.44.6          March 2019                         MKE2FS(8)
Impressum