MKE2FS(8)
โจ NAME โจ
mke2fs โ create an ext2/ext3/ext4 file system ๐
(also, hi bestie, this is from section 8, the System Manager's Manual โ the big-girl system admin pages ๐ )
๐ธ SYNOPSIS ๐ธ
mke2fs [ -c | -l filename ] [ -b block-size ] [ -C cluster-size ] [ -d
root-directory|tarball|- ] [ -D ] [ -g blocks-per-group ] [ -G number-
of-groups ] [ -i bytes-per-inode ] [ -I inode-size ] [ -j ] [ -J
journal-options ] [ -N number-of-inodes ] [ -n ] [ -m reserved-blocks-
percentage ] [ -o creator-os ] [ -O [^]feature[,...] ] [ -q ] [ -E
extended-options ] [ -v ] [ -F ] [ -L volume-label ] [ -M last-mounted-
directory ] [ -S ] [ -t fs-type ] [ -T usage-type ] [ -U UUID ] [ -V ] [
-e errors-behavior ] [ -z undo_file ] device [ fs-size ]
mke2fs -O journal_dev [ -b block-size ] [ -L volume-label ] [ -n ] [ -q
] [ -v ] external-journal [ fs-size ]
๐ฆ DESCRIPTION ๐ฆ
mke2fs is the girl who makes file systems. She creates an ext2, ext3, or ext4 file system, usually inside a disk partition (or a file, no judgment) that you name with device. Iconic behaviour, honestly. ๐
The size of the file system is set by fs-size. And here's the tea on how that number gets read:
- If fs-size has no suffix, it's interpreted as power-of-two kilobytes โ unless you also passed the
-bblock-size option, in which case fs-size is read as the number of block-size blocks. - If fs-size is suffixed with
'k','m','g','t'(upper-case or lower-case, she's not picky ๐ซถ), it's interpreted in power-of-two kilobytes, megabytes, gigabytes, terabytes, etc. - If fs-size is just... omitted? Then
mke2fscreates the file system based on the device size. Let her cook. โจ
If mke2fs is run as mkfs.XXX (that's mkfs.ext2, mkfs.ext3, or mkfs.ext4), then the -t XXX option is implied โ so mkfs.ext3 makes a file system for use with ext3, mkfs.ext4 makes one for ext4, and so on down the line. It's giving "I already know what you want". ๐
The defaults for the parameters of your brand-new file system, whenever you haven't overridden them with the options listed below, are controlled by the /etc/mke2fs.conf configuration file. Go read mke2fs.conf(5) for the details, bestie, it's all in there. ๐
๐ OPTIONS ๐
-bblock-size โ set the size of blocks, in bytes. Valid block-size values are powers of two from1024up to65536โ but โ ๏ธ keep in mind the kernel can only mount file systems whose block-size is smaller than or equal to the system page size: that's4kon x86 systems, and up to64kon ppc64 or aarch64 depending on kernel configuration. If you omit it, block-size gets heuristically determined from the file system size and the expected usage of the file system (peep the-Toption). In most common cases the default block size is4k. And here's the fun bit: if block-size is preceded by a negative sign ('-'),mke2fsuses heuristics to figure out the appropriate block size, with the constraint that the block size will be at least block-size bytes. That's useful for certain hardware devices that require the blocksize to be a multiple of2k. Slay for weird hardware. ๐ฅ-cโ check the device for bad blocks before creating the file system. If you specify this option twice, a slower read-write test is used instead of the fast read-only test. Double it and give it to the next person, I guess. ๐ญ-Ccluster-size โ specify the size of clusters in bytes for file systems using thebigallocfeature. Valid cluster-size values range from2to32768times the filesystem block size, and it must be a power of2. You can only specify cluster-size if thebigallocfeature is enabled. (Checkext4(5)for more details aboutbigalloc, no cap.) The default cluster size whenbigallocis enabled is16times the block size. ๐ง-droot-directory|tarball|-โ copy the contents of the given directory or tarball into the root directory of the file system. Tarball input is only available ifmke2fswas compiled with libarchive support enabled and if the libarchive shared library is available at run-time. The special value-will read a tarball from standard input. So extra. Obsessed. ๐-Dโ use direct I/O when writing to the disk. This avoidsmke2fsdirtying a lot of buffer cache memory, which may impact other applications running on a busy server. However โ and this is the tradeoff, bestie โ this option will causemke2fsto run much more slowly. So it's a whole tradeoff situation with direct I/O. ๐-eerror-behavior โ change the behavior of the kernel code when errors are detected. In all cases, a file system error will causee2fsck(8)to check the file system on the next boot. error-behavior can be one of these:continueโ continue normal execution.remount-roโ remount file system read-only.panicโ cause a kernel panic. ๐ฑ
-Eextended-options โ set extended options for the file system. Extended options are comma separated, and may take an argument using the equals ('=') sign. Multiple-Eoptions may also be used. Fun history moment: the-Eoption used to be-Rin earlier versions ofmke2fs. The-Roption is still accepted for backwards compatibility, but it is deprecated. ๐ซ The following extended options are supported:assume_storage_prezeroed[=<0 to disable | 1 to enable>]โ if enabled,mke2fsassumes that the storage device has been prezeroed, skips zeroing the journal and inode tables, and annotates the block group flags to signal that the inode table has been zeroed.discardโ attempt to discard blocks at mkfs time (discarding blocks initially is useful on solid state devices and sparse / thin-provisioned storage). When the device advertises that discard also zeroes data (any subsequent read after the discard and before write returns zero), then mark all not-yet-zeroed inode tables as zeroed. This significantly speeds up file system initialization. This is set as default. โญencoding=encoding-name โ enable thecasefoldfeature in the super block and set encoding-name as the encoding to be used. If encoding-name is not specified, the encoding defined inmke2fs.conf(5)is used.encoding_flags=encoding-flags โ define parameters for file name character encoding operations. If a flag is not changed using this parameter, its default value is used. encoding-flags should be a comma-separated lists of flags to be enabled. To disable a flag, add it to the list with the prefix"no".
The only flag that can be set right now is strict, which means that invalid strings should be rejected by the file system. In the default configuration, the strict flag is disabled.
hash_seed=UUID โ use the specified UUID as the seed for hashing, rather than generating a random seed each time. Intended for use with reproducible builds. Reproducible girlies rise up. ๐lazy_itable_init[=<0 to disable | 1 to enable>]โ if enabled and theuninit_bgfeature is enabled, the inode table will not be fully initialized bymke2fs. This speeds up file system initialization noticeably, but it requires the kernel to finish initializing the file system in the background when the file system is first mounted. If the option value is omitted, it defaults to1to enable lazy inode table zeroing.lazy_journal_init[=<0 to disable | 1 to enable>]โ if enabled, the journal inode will not be fully zeroed out bymke2fs. This speeds up file system initialization noticeably, but it carries some small risk if the system crashes before the journal has been overwritten entirely one time. ๐ฌ If the option value is omitted, it defaults to1to enable lazy journal inode zeroing.mmp_update_interval=interval โ adjust the initial MMP update interval to interval seconds. Specifying an interval of0means to use the default interval. The specified interval must be less than300seconds. Requires that themmpfeature be enabled.nodiscardโ do not attempt to discard blocks at mkfs time. (the anti-discard, if you will ๐)no_copy_xattrsโ normallymke2fswill copy the extended attributes of the files in the directory hierarchy specified via the (optional)-doption. This will disable the copy and leaves the files in the newly created file system without any extended attributes.num_backup_sb=<0|1|2>โ if thesparse_super2file system feature is enabled, this option controls whether there will be0,1, or2backup superblocks created in the file system.offset=offset โ create the file system at an offset from the beginning of the device or file. This can be useful when creating disk images for virtual machines. ๐ฅ๏ธorphan_file_size=size โ set size of the file for tracking unlinked but still open inodes and inodes with truncate in progress. Larger file allows for better scalability; reserving a few blocks per CPU is ideal.packed_meta_blocks[=<0 to disable | 1 to enable>]โ place the allocation bitmaps and the inode table at the beginning of the disk. This option requires that theflex_bgfile system feature to be enabled in order for it to have effect, and will also create the journal at the beginning of the file system. This option is useful for flash devices that use SLC flash at the beginning of the disk. It also maximizes the range of contiguous data blocks, which can be useful for certain specialized use cases, such as supported Shingled Drives.
okay bestie that's the first chunk and there is so much more coming โ don't go anywhere ๐
quotatype=quota-type[:...]โ tell mke2fs which quota types to switch on in the brand-new filesystem. Your options areusrquota,grpquota, andprjquota, and bestie you write them as a colon-separated list. Heads up tho: this only does anything if thequotafeature is actually set. If you don't specify it at all, the default quota types that get initialized are both user and group quotas. And if theprojectfeature is enabled, then project quotas get initialized too. ๐resize=max-online-resizeโ reserve enough space so the block group descriptor table can grow big enough to support a filesystem that hasmax-online-resizeblocks. Future-proofing queen. โจrevision=fs-revisionโ set the filesystem revision number. Revision 0 filesystems play nice with pre-1.2 Linux kernels (so like, before 1995 ๐ญ). You only need this for testing or for the girlies who genuinely want to run extremely early, historical Linux systems. The current default โ and the one every modern Linux supports โ is revision 1. Periodt.root_owner[=uid:gid]โ set the numeric user and group ID of the root directory. If you don't give aUID:GID, it uses the user and group ID of whoever is runningmke2fs. Quick lore drop: in mke2fs 1.42 and earlier, the UID and GID of the root directory were set by default to the UID and GID of the user running themke2fscommand. Theroot_owner=option lets you specify these values explicitly and dodge the side-effects for users who do not expect the contents of the filesystem to change based on who ranmke2fs. Iconic, honestly.root_perms[=permissions]โ set the root directory permissions in octal format. If you don't give any permissions, the root directory permissions get set according to the default filesystemumask. No cap.root_selinux=labelโ set the root directory's SELinux security context aslabel, typicallysystem_u:object_r:root_t, with an optional level/range suffix such as:s0for MCS/MLS policy types. ๐ซถstride=stride-sizeโ configure the filesystem for a RAID array withstride-sizefilesystem blocks. This is the number of blocks read or written to disk before moving on to the next disk, which some people call the chunk size. It mostly affects where filesystem metadata like bitmaps get placed at mke2fs time, so they don't all end up stacked on one disk โ which would hurt performance. It may also be used by the block allocator. Lowkey important. ๐ฅstripe_width=stripe-widthโ configure the filesystem for a RAID array withstripe-widthfilesystem blocks per stripe. This is typicallystride-size * N, whereNis the number of data-bearing disks in the RAID (like, for RAID 5 there's one parity disk, soNis the number of disks in the array minus 1). This lets the block allocator avoid read-modify-write of the parity in a RAID stripe when possible while data is being written. Genius behaviour tbh. โจtest_fsโ set a flag in the filesystem superblock saying it may be mounted using experimental kernel code, such as theext4devfilesystem. ๐งช
-Fโ Forcemke2fsto create a filesystem even if the specified device isn't a partition on a block special device, or if other parameters just don't make sense. And if you want to forcemke2fsto create a filesystem even when the filesystem appears to be in use or is mounted โ which is a truly dangerous thing to do โ you have to specify this option twice. Not once. Twice. Respect the double. ๐-g blocks-per-groupโ specify the number of blocks in a block group. Ngl there's generally no reason for you to ever set this, because the default is optimal for the filesystem. (For admins creating filesystems on RAID arrays, it's preferable to use the-E stride=extended option rather than messing with the number of blocks per group.) This one's generally used by developers working on test cases. Also: if thebigallocfeature is enabled, the-goption specifies the number of clusters in a block group. ๐-G number-of-groupsโ specify how many block groups get packed together to create a bigger virtual block group (a "flex_bg group") in an ext4 filesystem. This improves meta-data locality and performance on meta-data heavy workloads. The number of groups must be a power of 2, and you may only specify it if theflex_bgfilesystem feature is enabled. Rules are rules bestie. โจ-i bytes-per-inodeโ specify the bytes/inode ratio.mke2fscreates one inode for everybytes-per-inodebytes of space on the disk. The larger the ratio, the fewer inodes get made. This value generally shouldn't be smaller than the block-size of the filesystem, because then you'd be making more inodes than could ever be used. โ ๏ธ Be warned: it is not possible to change this ratio on a filesystem after it's created, so be careful deciding the correct value for this parameter. Also note that resizing a filesystem changes the number of inodes to maintain this ratio. Choose wisely, main character. ๐ญ-I inode-sizeโ specify the size of each inode in bytes. Theinode-sizevalue must be a power of 2 larger or equal to128. The larger theinode-size, the more space the inode table eats, which reduces usable space in the filesystem and can also negatively impact performance. And fr, it is not possible to change this value after the filesystem is created.
File systems with an inode size of 128 bytes do not support timestamps beyond January 19, 2038. ๐ญ Inodes that are 256 bytes or larger will support extended timestamps, project id's, and the ability to store some extended attributes in the inode table for improved performance. Glow-up.
The default inode size is controlled by the mke2fs.conf(5) file. In the mke2fs.conf file shipped with e2fsprogs, the default inode size is 256 bytes for all filesystems, except for the GNU Hurd since it only supports 128-byte inodes. ๐ง
-jโ create the filesystem with an ext3 journal. If the-Joption isn't specified, the default journal parameters get used to create an appropriately sized journal (given the size of the filesystem) stored within the filesystem. Note that you must be using a kernel with ext3 support to actually make use of the journal. No kernel support, no journal magic. ๐ซ-J journal-optionsโ create the ext3 journal using options specified on the command line. Journal options are comma separated, and may take an argument using the equals (=) sign. The following journal options are supported:device=external-journalโ attach the filesystem to the journal block device located onexternal-journal. The external journal must already have been created using the command:
mke2fs -O journal_dev external-journal
Note that external-journal must have been created with the same block size as the new filesystem. In addition, while there's support for attaching multiple filesystems to a single external journal, the Linux kernel and e2fsck(8) do not currently support shared external journals yet.
Instead of specifying a device name directly, external-journal can also be specified by either LABEL=label or UUID=UUID to locate the external journal by either the volume label or UUID stored in the ext2 superblock at the start of the journal. Use dumpe2fs(8) to display a journal device's volume label and UUID. See also the -L option of tune2fs(8). ๐
fast_commit_size=fast-commit-sizeโ create an additional fast commit journal area of sizefast-commit-sizekilobytes. This option is only valid if thefast_commitfeature is enabled on the filesystem. If this option isn't specified and thefast_commitfeature is turned on, the fast commit area size defaults tojournal-size / 64megabytes. The total size of the journal with thefast_commitfeature set isjournal-size + ( fast-commit-size * 1024 )megabytes. The total journal size may be no more than10,240,000filesystem blocks or half the total filesystem size โ whichever is smaller.location=journal-locationโ specify the location of the journal. The argumentjournal-locationcan either be given as a block number, or, if the number has a units suffix (e.g.,'M','G', etc.), it's interpreted as the offset from the beginning of the filesystem. ๐size=journal-sizeโ create an internal journal (like, stored inside the filesystem) of sizejournal-sizemegabytes. The size of the journal must be at least1024filesystem blocks (that's1MBif using 1k blocks,4MBif using 4k blocks, etc.) and may be no more than10,240,000filesystem blocks or half the total filesystem size โ whichever is smaller. โจ
Only one of the size or device options can be given for a filesystem. Pick a lane bestie. ๐
-l filenameโ Read the bad blocks list from filename. Heads up, bestie: the block numbers in that bad block list must be generated using the same block size as used bymke2fs. So basically, the-coption tomke2fsis a much simpler and less error-prone method of checking a disk for bad blocks before formatting it, becausemke2fswill automatically pass the correct parameters to thebadblocks(8)program. slay.-L new-volume-labelโ Set the volume label for the file system to new-volume-label. The maximum length of the volume label is 16 bytes. Keep it cute and short, okay?-m reserved-blocks-percentageโ Specify the percentage of the file system blocks reserved for the super-user. This avoids fragmentation, and allows root-owned daemons, such assyslogd(8), to continue to function correctly after non-privileged processes are prevented from writing to the file system. The default percentage is 5%. Bestie, don't touch it unless you know what you're doing.-M last-mounted-directoryโ Set the last mounted directory for the file system. This might be useful for the sake of utilities that key off of the last mounted directory to determine where the file system should be mounted. iykyk.-nโ Causesmke2fsto not actually create a file system, but display what it would do if it were to create a file system. This can be used to determine the location of the backup superblocks for a particular file system, so long as themke2fsparameters that were passed when the file system was originally created are used again. (With the-noption added, of course!) Iconic dry-run energy.-N number-of-inodesโ Overrides the default calculation of the number of inodes that should be reserved for the file system (which is based on the number of blocks and thebytes-per-inoderatio). This allows the user to specify the number of desired inodes directly. Direct control? Obsessed.-o creator-osโ Overrides the default value of the "creator operating system" field of the file system. The creator field is set by default to the name of the OS themke2fsexecutable was compiled for. So it's like a lil name tag for your filesystem.-O [^]feature[,...]โ Create a file system with the given features (file system options), overriding the default file system options.
The features that are enabled by default are specified by the base_features relation, either in the [defaults] section in the /etc/mke2fs.conf configuration file, or in the [fs_types] subsections for the usage types as specified by the -T option, further modified by the features relation found in the [fs_types] subsections for the file system and usage types. See the mke2fs.conf(5) manual page for more details. The file system type-specific configuration setting found in the [fs_types] section will override the global default found in [defaults].
The file system feature set will be further edited using either the feature set specified by this option, or if this option is not given, by the default_features relation for the file system type being created, or in the [defaults] section of the configuration file.
The file system feature set is comprised of a list of features, separated by commas, that are to be enabled. To disable a feature, simply prefix the feature name with a caret ('^') character. Features with dependencies will not be removed successfully. The pseudo-file system feature "none" will clear all file system features.
For more information about the features which can be set, please see the manual page ext4(5). Feature queen behavior.
-qโ Quiet execution. Useful ifmke2fsis run in a script. No yapping, just vibes.-Sโ Write superblock and group descriptors only. This is an extreme measure to be taken only in the very unlikely case that all of the superblock and backup superblocks are corrupted, and a last-ditch recovery method is desired by experienced users. It causesmke2fsto reinitialize the superblock and group descriptors, while not touching the inode table and the block and inode bitmaps. Thee2fsck(8)program should be run immediately after this option is used, and there is no guarantee that any data will be salvageable.
Danger, bestie: Due to the wide variety of possible options tomke2fsthat affect the on-disk layout, it is critical to specify exactly the same format options, such asblock-size,fs-type,feature flags, and other tunables when using this option, or the file system will be further corrupted. In some cases, such as file systems that have been resized, or have had features enabled after format time, it is impossible to overwrite all of the superblocks correctly, and at least some file system corruption will occur. It is best to run this on a full copy of the file system so other options can be tried if this doesn't work.
-t fs-typeโ Specify the file system type (i.e.,ext2,ext3,ext4, etc.) that is to be created. If this option is not specified,mke2fswill pick a default either via how the command was run (for example, using a name of the formmkfs.ext2,mkfs.ext3, etc.) or via a default as defined by the/etc/mke2fs.conffile. This option controls which file system options are used by default, based on the[fs_types]configuration stanza in/etc/mke2fs.conf.
If the -O option is used to explicitly add or remove file system options that should be set in the newly created file system, the resulting file system may not be supported by the requested fs-type. (e.g., "mke2fs -t ext3 -O extent /dev/sdXX" will create a file system that is not supported by the ext3 implementation as found in the Linux kernel; and "mke2fs -t ext3 -O ^has_journal /dev/hdXX" will create a file system that does not have a journal and hence will not be supported by the ext3 file system code in the Linux kernel.) So don't mix and match unless you're ready for chaos.
-T usage-type[,...]โ Specify how the file system is going to be used, so thatmke2fscan choose optimal file system parameters for that use. The usage types that are supported are defined in the configuration file/etc/mke2fs.conf(5). The user may specify one or more usage types using a comma separated list.
If this option is not specified, mke2fs will pick a single default usage type based on the size of the file system to be created. If the file system size is less than 3 megabytes, mke2fs will use the file system type floppy. If the file system size is greater than or equal to 3 but less than 512 megabytes, mke2fs will use the file system type small. If the file system size is greater than or equal to 4 terabytes but less than 16 terabytes, mke2fs will use the file system type big. If the file system size is greater than or equal to 16 terabytes, mke2fs will use the file system type huge. Otherwise, mke2fs will use the default file system type default. Size type queen, not size queen.
-U UUIDโ Set the universally unique identifier (UUID) of the file system to UUID. The format of the UUID is a series of hex digits separated by hyphens, like this:"c1b9d5a2-f162-11cf-9ece-0020afc76f16". The UUID parameter may also be one of the following:clearโ clear the file system UUIDrandomโ generate a new randomly-generated UUIDtimeโ generate a new time-based UUID
UUIDs are iconic, periodt.
-vโ Verbose execution. Tell me everything, king.-Vโ Print the version number ofmke2fsand exit. Short and sweet.-z undo_fileโ Before overwriting a file system block, write the old contents of the block to an undo file. This undo file can be used withe2undo(8)to restore the old contents of the file system should something go wrong. If the empty string is passed as the undo_file argument, the undo file will be written to a file namedmke2fs-device.e2undoin the directory specified via theE2FSPROGS_UNDO_DIRenvironment variable or theundo_dirdirective in the configuration file.
WARNING: The undo file cannot be used to recover from a power or system crash.
Not a time machine, bestie. Sorry.
โจ ENVIRONMENT โจ
MKE2FS_SYNCโ If set to non-zero integer value, its value is used to determine how oftensync(2)is called during inode table initialization. Sync queen.MKE2FS_CONFIGโ Determines the location of the configuration file (seemke2fs.conf(5)). Config file finder.MKE2FS_FIRST_META_BGโ If set to non-zero integer value, its value is used to determine first meta block group. This is mostly for debugging purposes. Debug vibes only.MKE2FS_DEVICE_SECTSIZEโ If set to non-zero integer value, its value is used to determine logical sector size of the device. Sector size, but make it logical.MKE2FS_DEVICE_PHYS_SECTSIZEโ If set to non-zero integer value, its value is used to determine physical sector size of the device. Physical, not logical. We love a distinction.MKE2FS_SKIP_CHECK_MSGโ If set, do not show the message of file system automatic check caused by mount count or check interval. Skip the pop-up, got it.
๐ AUTHOR ๐
This version of mke2fs has been written by Theodore Ts'o <tytso@mit.edu>. Legend.
๐ AVAILABILITY ๐
mke2fs is part of the e2fsprogs package and is available from http://e2fsprogs.sourceforge.net. Go get it, bestie.
๐ SEE ALSO ๐
๐ That's a wrap on MKE2FS(8) โ from e2fsprogs version 1.47.4, dated March 2025. Mwah! ๐
๐ฆ where this page comes from
- alpine 3.24: e2fsprogs-doc 1.47.4-r0 ยท GPL-2.0-or-later AND LGPL-2.0-or-later AND BSD-3-Clause AND MIT
- arch rolling: e2fsprogs 1.47.4-1 ยท GPL AND LGPL AND MIT
- nixpkgs unstable: e2fsprogs 1.47.4
- ubuntu stonking: e2fsprogs 1.47.4-1 ยท GPL-2.0-only
- Copyright 1993, 1994, 1995 by Theodore Ts'o. All Rights Reserved
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms