mke2fs Command in Linux: Syntax, Options & ext Filesystem Examples

mke2fs builds ext2, ext3, or ext4 filesystems on a block device or image file. It is the low-level formatter behind mkfs.ext4 and writes the superblock, inode tables, journal, and default mount metadata for e2fsprogs-managed volumes.

Published

Updated

Read time 9 min read

Reviewed byDeepak Prasad

mke2fs Command in Linux: Syntax, Options & ext Filesystem Examples
About mke2fs builds ext2, ext3, or ext4 filesystems on a block device or image file. It is the low-level formatter behind mkfs.ext4 and writes the superblock, inode tables, journal, and default mount metadata for e2fsprogs-managed volumes.
Tested on Ubuntu 25.04 (Plucky Puffin); mke2fs 1.47.2 (e2fsprogs 1.47.2-1ubuntu1); kernel 7.0.0-27-generic
Package e2fsprogs (apt/deb) · e2fsprogs (dnf/rpm)
Man page mke2fs(8)
Privilege root / sudo
Distros

Ubuntu, Debian, RHEL, AlmaLinux, Fedora, and other distros shipping e2fsprogs.

High-level wrappers: mkfs.ext4 calls mke2fs; after creation use tune2fs to adjust labels and check intervals.

Related guide

mke2fs — quick reference

Create a filesystem

Format an empty partition, LVM logical volume, or loop device. Default type on Ubuntu 25.04 follows /etc/mke2fs.conf (usually ext4).

When to use Command
Create a filesystem with the distro default type (ext4 on Ubuntu) sudo mke2fs /dev/sdX1
Force ext4 explicitly sudo mke2fs -t ext4 /dev/sdX1
Create ext3 (journal added during format) sudo mke2fs -t ext3 /dev/sdX1
Create ext2 (no journal) sudo mke2fs -t ext2 /dev/sdX1
Dry run — show what would be created without writing sudo mke2fs -n /dev/sdX1
Force format even when the target looks unusual (use with care) sudo mke2fs -F /dev/sdX1

Block and inode layout

Tune space efficiency before data is written. Inode count is fixed at creation time.

When to use Command
Set block size to 1024, 2048, or 4096 bytes sudo mke2fs -b 4096 /dev/sdX1
Fewer inodes — one inode per N bytes of capacity sudo mke2fs -i 8192 /dev/sdX1
Larger inode structures (256 bytes is the modern default) sudo mke2fs -I 512 /dev/sdX1
Reserve a percentage of blocks for root (default from mke2fs.conf) sudo mke2fs -m 1 /dev/sdX1

Labels, mount path, and UUID

Metadata stored in the superblock — readable later with tune2fs or dumpe2fs.

When to use Command
Set the volume label shown in lsblk and /etc/fstab sudo mke2fs -L DATA /dev/sdX1
Record the intended mount point in the superblock sudo mke2fs -M /mnt/data /dev/sdX1
Assign a specific filesystem UUID at creation sudo mke2fs -U 12345678-1234-1234-1234-123456789abc /dev/sdX1

Journal and features

ext4 is created with a journal by default on current e2fsprogs. Use -j when you need a journal on ext2, or -O for feature flags.

When to use Command
Add an ext3-style journal while formatting sudo mke2fs -j /dev/sdX1
Enable or disable ext4 feature flags sudo mke2fs -O has_journal,extent /dev/sdX1
Skip the journal on a new ext4 filesystem sudo mke2fs -O ^has_journal /dev/sdX1

Integrity checks

Run before production use on suspect media.

When to use Command
Read-only bad-block scan before formatting sudo mke2fs -c /dev/sdX1

Output control

mke2fs does not support --help; pass invalid flags or run bare mke2fs to print usage on stderr.

When to use Command
Show version and linked ext2fs library mke2fs -V
Quiet format — only errors sudo mke2fs -q /dev/sdX1
Verbose progress sudo mke2fs -v /dev/sdX1

mke2fs — command syntax

Synopsis from mke2fs usage text on Ubuntu 25.04 (e2fsprogs 1.47.2):

text
mke2fs [-c|-l filename] [-b block-size] [-C cluster-size]
	[-i bytes-per-inode] [-I inode-size] [-J journal-options]
	[-G flex-group-size] [-N number-of-inodes] [-d root-directory|tarball]
	[-m reserved-blocks-percentage] [-o creator-os]
	[-g blocks-per-group] [-L volume-label] [-M last-mounted-directory]
	[-O feature[,...]] [-E extended-option[,...]] [-t fs-type]
	[-T usage-type ] [-U UUID] [-e errors_behavior][-z undo_file]
	[-jnqvDFSV] device [blocks-count]

mke2fs writes the superblock, block and inode bitmaps, and (for ext3/ext4) the journal on the target device. It destroys existing data on that device. Most examples need sudo.


mke2fs — command examples

Essential Default ext4 on a loop-backed test image

Practice on a file-backed block device before formatting real disks. Create a sparse image, attach it with losetup, then run mke2fs with no type flag — Ubuntu defaults to ext4.

Run the commands:

bash
dd if=/dev/zero of=/tmp/test.img bs=1M count=64 status=none
sudo losetup -f --show /tmp/test.img

Sample output (loop number varies):

text
/dev/loop27

Format the loop device (replace loop27 with your device):

bash
sudo mke2fs /dev/loop27

Sample output:

output
mke2fs 1.47.2 (1-Jan-2025)
Creating filesystem with 16384 4k blocks and 16384 inodes
Filesystem UUID: 8f3c2a10-4b2e-4f1a-9c8d-1e2f3a4b5c6d
Superblock backups stored on blocks:
	4096, 12288

Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

Confirm the filesystem type and clean up:

bash
sudo blkid /dev/loop27
sudo losetup -d /dev/loop27
rm -f /tmp/test.img

Sample blkid line:

text
/dev/loop27: UUID="..." BLOCK_SIZE="4096" TYPE="ext4"
Essential ext4 with a volume label

Set the label at format time so /etc/fstab and lsblk -f show a friendly name without a separate tune2fs run.

bash
dd if=/dev/zero of=/tmp/label.img bs=1M count=32 status=none
LOOP=$(sudo losetup -f --show /tmp/label.img)
sudo mke2fs -t ext4 -L golinux $LOOP
sudo tune2fs -l $LOOP | grep 'Filesystem volume name'
sudo losetup -d $LOOP && rm -f /tmp/label.img

Sample output:

output
Filesystem volume name:   golinux
Essential Dry run with -n before touching production disks

-n prints the layout plan and exits without writing superblocks — useful to check inode and block counts on a new LVM volume.

bash
dd if=/dev/zero of=/tmp/dry.img bs=1M count=64 status=none
LOOP=$(sudo losetup -f --show /tmp/dry.img)
sudo mke2fs -n $LOOP
sudo losetup -d $LOOP && rm -f /tmp/dry.img

Sample output:

output
mke2fs 1.47.2 (1-Jan-2025)
Creating filesystem with 16384 4k blocks and 16384 inodes
Filesystem UUID: ...
Superblock backups stored on blocks:
	4096, 12288

No "Writing inode tables" lines appear — nothing was changed on disk.

Common Custom block size and bytes-per-inode ratio

Smaller blocks suit tiny filesystems; a larger -i value creates fewer inodes (good for mostly-large-file volumes). Inode count cannot grow after format.

bash
dd if=/dev/zero of=/tmp/ratio.img bs=1M count=32 status=none
LOOP=$(sudo losetup -f --show /tmp/ratio.img)
sudo mke2fs -b 2048 -i 8192 $LOOP
sudo dumpe2fs -h $LOOP 2>/dev/null | grep -E 'Block size|Inode count'
sudo losetup -d $LOOP && rm -f /tmp/ratio.img

Sample output:

output
Block size:               2048
Inode count:              4096
Common Larger inodes and explicit journal on ext2-style layout

-I 512 stores extended attributes in each inode. -j adds a journal (ext3 behaviour); modern -t ext4 already includes a journal.

bash
dd if=/dev/zero of=/tmp/j.img bs=1M count=32 status=none
LOOP=$(sudo losetup -f --show /tmp/j.img)
sudo mke2fs -I 512 -j $LOOP
sudo tune2fs -l $LOOP | grep 'Inode size'
sudo dumpe2fs -h $LOOP 2>/dev/null | grep 'Filesystem features'
sudo losetup -d $LOOP && rm -f /tmp/j.img

Sample output:

output
Inode size:               512
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype sparse_super large_file
Common Record the intended mount point with -M

-M stores "last mounted on" in the superblock — helpful documentation, not a live mount.

bash
dd if=/dev/zero of=/tmp/mnt.img bs=1M count=32 status=none
LOOP=$(sudo losetup -f --show /tmp/mnt.img)
sudo mke2fs -M /mnt $LOOP
sudo tune2fs -l $LOOP | grep 'Last mounted on'
sudo losetup -d $LOOP && rm -f /tmp/mnt.img

Sample output:

output
Last mounted on:          /mnt
Common Read-only bad-block scan with -c

-c runs a read-only test before allocating the filesystem. On large disks this can take hours; test on a small image first.

bash
dd if=/dev/zero of=/tmp/bad.img bs=1M count=16 status=none
LOOP=$(sudo losetup -f --show /tmp/bad.img)
sudo mke2fs -c $LOOP
sudo losetup -d $LOOP && rm -f /tmp/bad.img

Sample output (tail):

text
Checking for bad blocks (read-only test): done
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
Advanced Force format on a regular file with -F

Without -F, mke2fs refuses targets that are not block special devices. -F allows regular files and loop devices used in labs.

bash
dd if=/dev/zero of=/tmp/force.img bs=1M count=32 status=none
LOOP=$(sudo losetup -f --show /tmp/force.img)
sudo mke2fs -F $LOOP
sudo losetup -d $LOOP && rm -f /tmp/force.img

Pass -F twice only when you intentionally overwrite a mounted or in-use filesystem — that destroys live data.


mke2fs — when to use / when not

Use mke2fs when Use something else when
  • You are formatting a new partition, LVM volume, or loop device as ext2, ext3, or ext4
  • You need low-level control over block size, inode ratio, journal features, or reserved blocks at creation time
  • You are scripting ext filesystem creation and want the direct e2fsprogs binary
  • You want a dry run (-n) before writing to production storage
  • You only need the usual admin entry point → mkfs.ext4 (wrapper around mke2fs)
  • The volume is XFS, Btrfs, or VFAT → mkfs.xfs, mkfs.btrfs, mkfs.vfat
  • The filesystem already exists and you need to change the label or mount count → tune2fs
  • The filesystem is corrupt → e2fsck, not a reformat
  • You need read-only superblock inspection → dumpe2fs

mke2fs vs mkfs.ext4

mke2fs mkfs.ext4
Role Low-level ext formatter Symbolic link / wrapper to mke2fs with ext4 defaults
Typical use Scripts needing explicit -t, -O, or inode tuning Day-to-day mkfs.ext4 /dev/sdX1
Help text Usage on stderr (mke2fs with no args) mkfs.ext4 -h delegates to mke2fs

Both write the same on-disk ext4 structure when you pass equivalent flags.


Formatting and maintaining ext family filesystems on Linux.

Command One line
mke2fs Create ext2/ext3/ext4 (this page)

Browse the full index in our Linux commands reference.


mke2fs — interview corner

What does mke2fs do?

mke2fs is the e2fsprogs program that creates ext2, ext3, or ext4 filesystems. It lays down the superblock, block groups, inode tables, and (for journaled types) the journal. On most distros, mkfs.ext4 is a thin front end that calls mke2fs with ext4 defaults.

A strong answer is:

"mke2fs formats a block device as ext2, ext3, or ext4 — it writes the superblock and inode layout. mkfs.ext4 is the friendly wrapper most admins use day to day."

What filesystem type does mke2fs create by default?

On Ubuntu and Debian the default comes from /etc/mke2fs.conf — currently ext4 with a journal. You can override with -t ext3 or -t ext2. Run mke2fs -n DEVICE on a test volume to see the planned layout without writing.

A strong answer is:

"The default follows mke2fs.conf — ext4 on modern Ubuntu. I use -t when I need ext2 or ext3 explicitly, and -n for a dry run."

Why would you use -i bytes-per-inode?

The -i flag sets how many bytes of storage share each inode. A larger ratio means fewer inodes — good when the volume will hold mostly large files (logs, media). A smaller ratio means more inodes for many small files. Inode count is fixed at format time and cannot be expanded later without reformatting.

A strong answer is:

"-i controls bytes per inode — higher value, fewer inodes. I size it for the expected file mix because inode count is fixed at mkfs time."

What is the difference between mke2fs and tune2fs?

mke2fs runs at initial format and destroys existing data on the device. tune2fs changes tunable parameters on an existing ext filesystem — label, UUID, mount-count limits, reserved block percentage — without recreating the whole filesystem.

A strong answer is:

"mke2fs creates the filesystem; tune2fs adjusts parameters on an existing one. I never run mke2fs on a volume that still has data I need."

When is -F required?

mke2fs normally insists on a block device node. -F forces creation on unusual targets (regular files, some loop setups) or when metadata looks inconsistent. Using -F twice can overwrite a mounted filesystem — that is almost never appropriate in production.

A strong answer is:

"-F overrides safety checks for non-standard devices or odd metadata. I only use it in labs or when I'm certain the target is disposable."


Troubleshooting

Symptom Likely cause What to try
Device size reported to be zero Wrong device node or empty image Confirm with lsblk; extend the image or pick the correct partition
Filesystem too small Image or partition smaller than ext4 minimum Increase size with dd, parted, or LVM
mke2fs: invalid option Flag not in your e2fsprogs build Run bare mke2fs for usage text; check mke2fs -V
Device or resource busy Filesystem mounted umount first; never mke2fs a mounted production volume
contains a filesystem Existing signature detected Use wipefs -n DEVICE to inspect; reformat only if data loss is acceptable

References

Lab commands in this article were run on loop-backed files under /tmp on Ubuntu 25.04; production use targets partitions such as /dev/sdX1 or LVM paths like /dev/mapper/vg-lv.

Rohan Timalsina

is a technical writer and Linux enthusiast who writes practical guides on Linux commands and system administration. He focuses on simplifying complex topics through clear explanations.