mke2fs

Create ext2, ext3, and ext4 filesystems on Linux devices

Syntax

mke2fs [options] device

Basic Usage

Create ext2 filesystem

mke2fs /dev/sdb1

Creates an ext2 filesystem on the specified device.

Create ext3 filesystem

mke2fs -j /dev/sdb1

Create ext4 filesystem

mke2fs -t ext4 /dev/sdb1

Common Options

  • -t fstype: Specify filesystem type (ext2, ext3, ext4)
  • -j: Add journal (creates ext3 filesystem)
  • -L label: Set volume label
  • -N inodes: Set number of inodes
  • -i bytes-per-inode: Set bytes per inode ratio
  • -m percentage: Set percentage of blocks reserved for root
  • -c: Check for bad blocks before creating filesystem
  • -v: Verbose output
  • -F: Force creation without confirmation

Practical Examples

Create ext4 filesystem with label

mke2fs -t ext4 -L "DataDrive" /dev/sdb1

Create ext3 filesystem with custom inode count

mke2fs -j -N 100000 /dev/sdb1

Create ext4 filesystem with bad block check

mke2fs -t ext4 -c /dev/sdb1

Create ext2 filesystem with custom block reservation

mke2fs -m 2 /dev/sdb1

Create ext4 filesystem with custom inode ratio

mke2fs -t ext4 -i 8192 /dev/sdb1

Force creation without confirmation

mke2fs -F -t ext4 /dev/sdb1

Best Practices

Filesystem Selection

  • Use ext2 for simple, non-critical storage
  • Use ext3 for better recovery with journaling
  • Use ext4 for modern systems with better performance
  • Consider filesystem size and usage patterns

Important Warnings

  • This command will DESTROY all data on the device
  • Always double-check the device name before running
  • Ensure the device is not mounted
  • Backup any important data before formatting
  • Use with extreme caution on production systems

See Also

  • mkfs - High-level filesystem creation
  • fdisk - Partition table manipulation
  • mount - Mount filesystems
  • fsck - Check and repair filesystems