$linuxjunkies
>

mkfs.ext4(8)

Create an ext4 filesystem on a device or partition.

UbuntuDebianFedoraArch

Synopsis

mkfs.ext4 [OPTIONS] device [blocks-count]

Description

mkfs.ext4 creates a new ext4 filesystem on the specified device or partition. It initializes the inode table, block bitmap, and other filesystem structures needed for the ext4 journaling filesystem.

You must have root privileges to run this command. Always specify the correct device to avoid data loss—mkfs.ext4 will overwrite existing data without confirmation.

Common options

FlagWhat it does
-FForce creation even if the device is not a block device or is mounted
-L labelSet the filesystem label (up to 16 characters)
-m percentageSet percentage of blocks reserved for root (default 5%)
-b block-sizeSet block size in bytes: 1024, 2048, or 4096 (default 4096)
-i bytes-per-inodeSpecify bytes per inode ratio (default 16384)
-N number-of-inodesSpecify exact number of inodes to create
-E extended-optionsSet extended options like lazy_itable_init=1 or discard
-qQuiet mode—suppress progress reporting
-vVerbose output showing filesystem parameters
-T usage-typeSet filesystem optimization: small, default, largefile, largefile4

Examples

Create ext4 filesystem on /dev/sda1 with default settings

sudo mkfs.ext4 /dev/sda1

Create ext4 filesystem with label 'mydata' on /dev/sdb1

sudo mkfs.ext4 -L mydata /dev/sdb1

Create filesystem reserving only 2% of space for root instead of default 5%

sudo mkfs.ext4 -m 2 /dev/sdc1

Create filesystem with 4KB blocks and one inode per 8KB of space

sudo mkfs.ext4 -b 4096 -i 8192 /dev/sdd1

Create filesystem with lazy inode table initialization in quiet mode

sudo mkfs.ext4 -E lazy_itable_init=1 -q /dev/sde1

Create filesystem with approximately 1 million blocks, showing verbose output

sudo mkfs.ext4 -v /dev/sdf1 1000000

Related commands