mke2fs
disk managementLinux
The mke2fs command is one of the most frequently used commands in Linux/Unix-like operating systems. mke2fs Create an ext2/ext3/ext4 filesystem
Quick Reference
Command Name:
mke2fs
Category:
disk management
Platform:
Linux
Basic Usage:
mke2fs [options] [arguments]
Common Use Cases
Syntax
mke2fs [options] device [blocks-count]
Options
Option | Description |
---|---|
-b, --block-size=SIZE |
Block size in bytes (1024, 2048, or 4096) |
-c, --check |
Check for bad blocks before creating the filesystem |
-d, --root-directory=DIR |
Copy the contents of the specified directory to the root of the new filesystem |
-E, --extended-options=opts |
Set extended options for the filesystem |
-F, --force |
Force mke2fs to create a filesystem even if the specified device is not a block device, or if it's mounted |
-g, --blocks-per-group=BLOCKS |
Number of blocks in a block group |
-G, --group=blocks-per-group |
Number of blocks per group |
-i, --bytes-per-inode=BYTES |
Bytes per inode |
-I, --inode-size=SIZE |
Size of each inode in bytes |
-j, --journal |
Create an ext3 journal |
-J, --journal-options=opts |
Journal options for the filesystem |
-l, --bad-blocks-file=FILE |
Add the specified blocks listed in the FILE to the bad blocks list |
-L, --volume-label=LABEL |
Set the volume label for the filesystem |
-m, --reserved-blocks-percentage=PERCENT |
Percentage of blocks reserved for the super-user |
-M, --mounted-dir=DIR |
The directory where the filesystem will be mounted |
-n, --dry-run |
Don't actually create a filesystem, just show what would be done |
-N, --inodes=NUMBER |
Specify the number of inodes to create |
-O, --feature[,...], --features=feature[,...] |
Create a filesystem with the given features |
-q, --quiet |
Quiet execution (minimal output) |
-r, --fs-revision-level=REV |
Set the filesystem revision |
-S, --super-only |
Write superblock and group descriptors only |
-t, --type=fs-type |
Specify the filesystem type (ext2, ext3, or ext4) |
-T, --usage-type=type |
Specify how the filesystem will be used (e.g., news, largefile, etc.) |
-U, --uuid=UUID |
Set the UUID for the filesystem |
-v, --verbose |
Verbose execution |
Examples
How to Use These Examples
The examples below show common ways to use the mke2fs
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
mke2fs /dev/sdb1