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 creates the specified file system on the specified partition. For example, the following command creates an EXT3 file system on the /dev/sda1 partition.

creating ext3 file system

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

creating ext4 file system

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

creating 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 on it. An extended partition stores logical partitions. To store them, it uses a partition table. 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. If we confirm the operation, it creates a file system on the entire extended partition making the logical partitions inaccessible. You should never do this.

creating 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 file system on logical partition

Linux file systems

Linux uses EXT and XFS file systems.

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 very basic 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. This 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 very large files.

XFS

It was mainly developed for UNIX by Silicon Graphics. 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.

ComputerNetworkingNotes Linux Tutorials The mkfs command on Linux