The mkfs command on Linux

A file system creates the layout on the partition the operating system needs to store data. We cannot use a partition to store data if it does not have a file system. We use the mkfs command with the t option to create a file system on a partition. This command needs two arguments: the file system's name and the partition's path. It makes the specified file system on the selected partition. For example, the following command creates an EXT3 file system on the /dev/sda1 partition.

#mkfs -t ext3 /dev/sda1

Creating an ext3 file system

The following command creates an EXT4 file system on the /dev/sda2 partition.

#mkfs -t ext4 /dev/sda2

Creating an ext4 file system

The following command creates an XFS file system on the /dev/sda3 partition.

#mkfs -t xfs /dev/sda3

Creating an xfs file system

We can create a file system only on the partition that stores data. Since the extended partition does not store data, we can not create a file system. An extended partition contains logical partitions. It uses a partition table to store them. If we try to create a file system on it, the command finds this partition table and pauses the process. It prompts us to confirm the operation. Confirming the operation creates a file system on the extended partition, making the logical partitions inaccessible.

Creating an extended file system

We use logical partitions to store data. We can create file systems on them. The following command creates an EXT4 file system on the /dev/sda5 partition.

Creating a file system on logical partition

Linux file systems

Linux uses EXT and XFS file systems.

The ext and xfs file system

EXT

It was the first Linux file system. It was used in early versions of Linux.

EXT2

It was the second generation of the EXT file system. It provides essential features. It was developed in 1980. It was the default file system before RHEL5.

EXT3

It was the third generation of the EXT file system. It was the default file system in RHEL5. It was the first file system in the EXT series that supports the journaling mechanism. It supports a file up to 2 TB in size.

EXT4

It is the fourth generation of the EXT file system. It was the default file system in RHEL6. It uses a series of contiguous physical blocks on the hard disk known as extents. The extents are used to improve the performance of huge files.

XFS

Silicon Graphics developed it for UNIX. Later, it was adopted by most Linux distributions, including RHEL. It was the default file system in RHEL7. This file system is based on 64-bit extent. It uses journaling for metadata operations. It supports file systems and files of sizes up to 8 exabytes. The only drawback of this system is that it does not support the shrink feature like EXT3 and EXT4.

Conclusion

The mkfs command is a crucial tool for creating file systems on partitions, enabling the storage and organization of data. Various file systems, such as EXT3, EXT4, and XFS, cater to different needs and offer unique features. Understanding the differences among these file systems allows us to effectively manage data storage on Linux systems, ensuring optimal performance and accessibility.

ComputerNetworkingNotes Linux Tutorials The mkfs command on Linux

We do not accept any kind of Guest Post. Except Guest post submission, for any other query (such as adverting opportunity, product advertisement, feedback, suggestion, error reporting and technical issue) or simply just say to hello mail us ComputerNetworkingNotes@gmail.com