Basics of mke2fs command in Linux with examples
Last Updated :
23 Jul, 2025
mke2fs command is used to create a filesystem usually in form of a disk partition or file directly from the Linux terminal, it is a part of the e2fsprogs package.
The e2fsprogs package provides the following tools :
- mke2fs
- tune2fs
- dumpe2fs
- debugfs
Through mke2fs we can create ext2, ext3, or ext4 filesystems
Relation between mkfs and mke2fs :
We should keep in consideration that mkfs is part of the util-linux package and allows you to create filesystems of many different varieties, whereas mke2fs being a part of the e2fsprogs package used only to create ext2/3/4 filesystems.
Also, we should keep in consideration that mkfs calls mke2fs when it is requested to create an ext2/3/4 filesystem.
The basic syntax of mke2fs command :
mke2fs [ -c | -l filename ] [ -b block-size ] [ -f fragment-size ] [ -g blocks-per-group ] [ -G number-of-groups ] [ -i bytes-per-inode ] [ -I inode-size ] [ -j ] [ -J journal-options ] [ -K ] [ -N number-of-inodes ] [ -n ] [ -m reserved-blocks-percentage ] [ -o creator-os ] [ -O feature[,...] ] [ -q ] [ -r fs-revision-level ] [ -E extended-options ] [ -v ] [ -F ] [ -L volume-label ] [ -M last-mounted-directory ] [ -S ] [ -t fs-type ] [ -T usage-type ] [ -U UUID ] [ -V ] device [ blocks-count ]
mke2fs -O journal_dev [ -b block-size ] [ -L volume-label ] [ -n ] [ -q ] [ -v ] external-journal [ blocks-count ]
Note: mke2fs command is destructive. mke2fs places a new, formatted filesystem onto the partition. typing the wrong partition name will overwrite all existing data!!
Some Basic Commands :
To avoid significant loss of data, it is recommended to use these commands after you have made a backup of your data.
For safe operation try executing these commands after making an image file and creating file systems within that. We can explore and experiment with file systems without a need for spare hardware. We’ll use the dd command to create our image file.
dd if=/dev/zero of=~/abcx.img bs=1M count=250
- bs: block size (1MB)
- count: number of blocks(250)
- the total size of our image file: 250 MB
1. To get mke2fs version:
mke2fs -V
2. To get the basic syntax for mke2fs along with the tags:
mke2fs
3. To find bad blocks and create an ext2 filesystem:
sudo mke2fs -c ~/abcx.img
Note: Specifying -c twice leads to a slower read-write test instead of a fast read-only when the -c is specified only once
4. To create a filesystem and quickly check for bad blocks:
sudo mke2fs -t fs_type -c ~/abcx.img
In the command above -t is used for specifying the filesystem type we want to create followed by fs_type which can be replaced by ext2/3/4.
5. To create an ext4 filesystem with a BACKUP volume label:
sudo mke2fs -t ext4 -L BACKUP ~/abcx.img
6. To create an ext4 filesystem with 8290 bytes per inode, with a volume label BACKUP:
sudo mke2fs -t ext4 -L BACKUP -i 8290 ~/abcx.img
7. To find the number of bytes per inode:
df -i /dev/sdb
Similar Reads
mkfs Command in Linux with Examples The mkfs command stands for âmake file systemâ and is utilized to create a file system, which organizes a hierarchy of directories, subdirectories, and files, on a formatted storage device. This can be a partition on a hard disk drive (HDD), a USB drive, or other storage media. A partition is a logi
4 min read
cfdisk command in Linux with examples cfdisk command is used to create, delete, and modify partitions on a disk device. It displays or manipulates the disk partition table by providing a text-based "graphical" interface. cfdisk /dev/sda Example: After running you get a prompt like this: Choose gpt from the list. Now you will see a parti
3 min read
Linux tune2fs command With Examples Linux, as a versatile and powerful operating system, offers a myriad of command-line tools to manage and manipulate various aspects of the file system. Among these tools, the tune2fs command stands out as a crucial utility for fine-tuning the ext2, ext3, and ext4 file systems. This command empowers
5 min read
readelf command in Linux with Examples When we compile source code, an object file is generated of the program and with the help of linker, this object files gets converted to a binary file which, only the machine can understand. This kind of file follows some structures one of which is ELF(Executable and Linkable Format). And to get the
4 min read
Linux make Command with Examples The make command for Linux is a very useful utility in the automation of software development and performing tasks in a Linux environment. It simply reads a special file, which is called a Makefile and this file describes how one's program is compiled and linked with another file or another program
6 min read
sync command in Linux with Examples sync command in Linux is used to synchronize cached writes to persistent storage. If one or more files are specified, sync only them, or their containing file systems. Syntax: sync [OPTION] [FILE]... Note: Nothing is being shown in the screenshots just because sync command makes the cache in the bac
1 min read