mke2fs Command in Linux
Build an AI-First Career, Master the Complete Skillset
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
AI Forward Deployed Engineer Program
Full-stack engineering, production AI and client-facing consulting
+1000 moreOverview
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.
Options in mke2fs Command in Linux
-
-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.
-
-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.
-
-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.
How Scaler Transformed Careers in Different Fields
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
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
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.