• 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. EFS Mount Issue “Failed to resolve server: Name or service not known”
  2. How to set “max_report_luns” and “max_luns” on CentOS/RHEL 7 to scan more than 16,383 LUNs
  3. How to grep with color output
  4. How to block non-root user from creating crontab entry in Linux
  5. Integrate Linux Servers with Active Directory using Samba, Winbind, and Kerberos
  6. How to Back Up and Restore XFS File Systems (xfsdump / xfsrestore)
  7. How to Change the Default Timeout Settings for Telnet Session in CentOS/RHEL
  8. How to list all modules and check if they are enabled or disabled in CentOS/RHEL 8
  9. CentOS / RHEL 7 : Booting process
  10. cp: omitting directory – error while copying a directory in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright