← 返回命令列表

Linux command

mke2fs 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Example

sudo mke2fs -t ext2 [/dev/sdXY]

Example

sudo mke2fs -t ext3 [/dev/sdXY]

Example

sudo mke2fs -t ext4 [/dev/sdXY]

Example

sudo mke2fs -t ext4 -L [my_label] [/dev/sdXY]

Dry-run

sudo mke2fs -n -t ext4 [/dev/sdXY]

Example

sudo mke2fs -t ext4 -m 0 [/dev/sdXY]

说明

mke2fs creates ext2, ext3, or ext4 filesystems on a device or partition. It initializes the superblock, block groups, inode tables, and other filesystem structures. The ext4 filesystem is the current standard for Linux, offering journaling, extents, and improved performance over ext2/ext3. The -t option selects the filesystem type and automatically enables appropriate features. Commonly invoked as mkfs.ext2, mkfs.ext3, or mkfs.ext4, which are symlinks to mke2fs with preset filesystem types. Defaults are read from /etc/mke2fs.conf.

参数

-t _type_
Filesystem type: ext2, ext3, or ext4
-L _label_
Set the volume label
-U _uuid_
Set the filesystem UUID
-b _size_
Block size in bytes (1024, 2048, or 4096)
-i _bytes-per-inode_
Bytes per inode ratio (affects number of inodes created)
-N _number_
Create exactly this many inodes
-m _percentage_
Reserved blocks percentage for root (default 5%)
-O _features_
Enable/disable filesystem features
-c
Check device for bad blocks before creating filesystem (use -cc for a read-write test).
-j
Create the filesystem with an ext3 journal.
-E _extended-options_
Set extended options (comma-separated), e.g. `discard`, `lazy_itable_init`, `stride`, `stripe_width`.
-T _usage-type_
Usage type (default, small, big, huge, news, largefile, largefile4) to tune defaults.
-n
Dry run: show what would be done without actually creating the filesystem (useful to locate backup superblocks).
-F
Force creation even if the target doesn't look like a partition or is in use. Specify twice to override all safety checks.
-q
Quiet mode (suppress informational output, useful in scripts).
-v
Verbose output.

FAQ

What is the mke2fs command used for?

mke2fs creates ext2, ext3, or ext4 filesystems on a device or partition. It initializes the superblock, block groups, inode tables, and other filesystem structures. The ext4 filesystem is the current standard for Linux, offering journaling, extents, and improved performance over ext2/ext3. The -t option selects the filesystem type and automatically enables appropriate features. Commonly invoked as mkfs.ext2, mkfs.ext3, or mkfs.ext4, which are symlinks to mke2fs with preset filesystem types. Defaults are read from /etc/mke2fs.conf.

How do I run a basic mke2fs example?

Run `sudo mke2fs -t ext2 [/dev/sdXY]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -t _type_ do in mke2fs?

Filesystem type: ext2, ext3, or ext4