mke2fs Command in Linux

Learn via video courses
Topics Covered

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Overview

Linux, being an open-source operating system, offers its users an array of powerful commands. The mke2fs command in Linux is one such robust utility that allows users to create ext2, ext3, or ext4 file systems. This command is a part of e2fsprogs package, which includes utilities to manage, repair, and manipulate ext2, ext3, and ext4 file systems. By default, it creates an ext2 file system, which can be changed as per user needs.

Syntax of mke2fs Command in Linux

The basic syntax of the mke2fs command in Linux is as follows:

Where:

  • options: The optional flags that change how the mke2fs command operates.
  • device: This is the path of the device where the file system is to be created.
  • size: This is the number of blocks on the file system.
Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course

Options in mke2fs Command in Linux

  1. -t type: Specifies the type of the file system. ext2, ext3, and ext4 are the available options.

    For example -

    Output:

    This command will create an ext3 file system on the /dev/sdb1 device.

  2. -b block-size: This option is used to specify the size of blocks in bytes. The values can be 1024, 2048, 4096 bytes per block.

    For example -

    Output:

    This command will create a file system with block size of 2048 bytes on the /dev/sdb1 device.

  3. -L volume-label: This option allows you to set a volume label for the file system.

    For example -

    Output:

    This command will create a file system with the label 'My Volume' on the /dev/sdb1 device.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Example Usages

  • Create a file system on a device:

    Output:

    Explanation: This command creates an ext2 file system on /dev/sdb1 with default parameters.

  • Create a file system with specified block size:

    Output:

    Explanation: This command creates an ext2 file system on /dev/sdb1 with a block size of 4096 bytes.

Tips

  • Always ensure to backup your data before executing the mke2fs command on a device.

  • You can use the -n option to run a simulation of the mke2fs command without actually creating the file system.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Advanced Use Cases of mke2fs Command in Linux

  • Creating a file system with a specified number of inodes:

    Output:

    Explanation: This command creates an ext2 file system on /dev/sdb1 with a specified number of 10000 inodes.

  • Creating an ext4 file system with journaling:

    Output:

    Explanation: This command creates an ext4 file system with journaling on /dev/sdb1.

Conclusion

  • The mke2fs command in Linux is a powerful tool for creating ext2, ext3, and ext4 file systems.

  • By understanding the syntax, options, and usage, you can use the mke2fs command efficiently.

  • Always ensure to backup your data before using the mke2fs command.