• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

mkfs.ext4 Command Examples in Linux

by admin

Ext4 is a native Linux filesystem, developed as the successor to ext3, and it was (and for some distributions still is) the default filesystem for many years. It offers stability, high capacity, reliability, and performance while requiring minimal maintenance. On top of that, you can resize (increase/decrease) the filesystem without a problem.

The mkfs.ext4 command can create an ext4 file system from disk partitions. This command is a symbolic link of the mke2fs command, and its usage is the same as the mke2fs command.

Syntax:

# mkfs [-t fstype] [fs_options] device

To create an ext4 filesystem, use:

# mkfs.ext4 -L [label] [partition]

The label is optional but makes it easier to recognize a filesystem.

Most Commonly used Command Options

Options Description
-c Check the partition for bad blocks before formatting
-q No information is displayed during execution
-b block-size Specify the block size, the default configuration file is in /etc/mke2fs.conf, blocksize = 4096
-F Forced formatting

mkfs.etx4 Command Examples

1. Format the disk /dev/sdd as a ext4 partition:

# mkfs.ext4 /dev/sdd

2. Check the partition for bad blocks before formatting:

# mkfs.ext4 -c /dev/sdb

3. Using defaults, quietly create an ext4 partition on /dev/hda3:

# mkfs.ext4 -q /dev/hda3

4. Create an ext4 filesystem labeled rootfs on existing partition /dev/hda3, checking for bad blocks and with full verbose output:

# mkfs.etx4 -L rootfs -cv /dev/hda3

Final Thoughts

Ext4 is not the fastest filesystem around, but for many workloads the gap between ext4 and the competition is very small.

The most important utilities are:

  • mkfs.ext4: Format the filesystem
  • e2label: Change the label of the filesystem
  • tune2fs: Change the parameters of the filesystem
  • dump2fs: Show the parameters of the filesystem
  • resize2fs: Change the size of the filesystem
  • fsck.ext4: Check and repair the filesystem
  • e2freefrag: Report on defragmentation
  • e4defrag: Defrag filesystem, normally not needed

Filed Under: Linux

Some more articles you might also be interested in …

  1. grep: command not found
  2. How to Check Btrfs FileSystem Usage and Perform Balancing
  3. amass viz – Visualize gathered information in a network graph (Command Examples)
  4. perf Command Examples in Linux
  5. wc Command Examples in Linux
  6. RCRON – Setup High Availability of cron Jobs
  7. pluma Command Examples in Linux
  8. fallocate Command Examples in Linux
  9. Linux OS Service ‘rpcidmapd’
  10. namei: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • aws ec2: CLI for AWS EC2 (Command Examples)
  • aws cur – Create, query, and delete AWS usage report definitions (Command Examples)
  • aws configure – Manage configuration for the AWS CLI (Command Examples)
  • aws cognito-idp: Manage Amazon Cognito user pool and its users and groups using the CLI

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright