mkfs.ext4(8)
Create an ext4 filesystem on a device or partition.
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
| Flag | What it does |
|---|---|
-F | Force creation even if the device is not a block device or is mounted |
-L label | Set the filesystem label (up to 16 characters) |
-m percentage | Set percentage of blocks reserved for root (default 5%) |
-b block-size | Set block size in bytes: 1024, 2048, or 4096 (default 4096) |
-i bytes-per-inode | Specify bytes per inode ratio (default 16384) |
-N number-of-inodes | Specify exact number of inodes to create |
-E extended-options | Set extended options like lazy_itable_init=1 or discard |
-q | Quiet mode—suppress progress reporting |
-v | Verbose output showing filesystem parameters |
-T usage-type | Set filesystem optimization: small, default, largefile, largefile4 |
Examples
Create ext4 filesystem on /dev/sda1 with default settings
sudo mkfs.ext4 /dev/sda1Create ext4 filesystem with label 'mydata' on /dev/sdb1
sudo mkfs.ext4 -L mydata /dev/sdb1Create filesystem reserving only 2% of space for root instead of default 5%
sudo mkfs.ext4 -m 2 /dev/sdc1Create filesystem with 4KB blocks and one inode per 8KB of space
sudo mkfs.ext4 -b 4096 -i 8192 /dev/sdd1Create filesystem with lazy inode table initialization in quiet mode
sudo mkfs.ext4 -E lazy_itable_init=1 -q /dev/sde1Create filesystem with approximately 1 million blocks, showing verbose output
sudo mkfs.ext4 -v /dev/sdf1 1000000