
Now that you have some background information, you can start using mkfs. dev/nvme0n1p2: Linux rev 1.0 ext4 filesystem data, UUID=34daa4b7-a2c4-4983-b5cc-df9baa6a6543 (extents) (64bit) (large files) (huge files) Real life use case: Using mkfs command to create a File System on a USB device Here's an example that shows what kind of output it could show: :~$ sudo file -s /dev/nvme0n1p2 You can use the file command for this purpose. You may want to check the type of filesystem of a device that you just formatted using mkfs command. sudo mkfs -c /dev/sdb1 Bonus tip: Check the filesystem type of a device You can also check for bad blocks on a device but keep in mind that the check often takes a long time. You can also use it like this: sudo mkfs.ext4 /dev/sdb1 Check for bad blocks on a device You can specify the file system in the following manner: sudo mkfs -t ext4 /dev/sdb1 Most Linux systems these days recommend using ext4. Using ext2 is not very convenient or advisable. sudo mkfs /dev/sdb1 Specify filetype with mkfs If you don't specify the filesystem type for the target device, it will use the default ext2 filesystem. mkfs without any option creates ext2 filesystem It will format the target device/disk partition erasing all the data. Please don't try any of these commands on your actual system blindly. Let me show you some of the most common usage of the mkfs command. Each use case is different, and it is up to you to decide what filesystem works best for your needs. This is why it is crucial to think about this before declaring a filesystem type, or "formatting" your device. Each of these address the logic of file structure differently which can result in issues. Generally speaking, FAT/ NTFS are designed for Windows, Ext is used with Linux systems, and APFS/HFS are macOS file systems. You may even associate the types with their respective operating systems. You have probably come across one or more of these filesystem types before. Here are the most common type of filesystems: There are many types of file systems and each has its own advantages and disadvantages.

The file system controls how data is stored and retrieved. You have been warned What is a file system, again?Ī file system (fs) refers to the structure and logic that manage data on a device. Selecting the wrong device node will erase all data on that device. It is important to understand the potential consequences of altering the filesystem.

Since the mkfs command deals with disks and partitions, it requires you to be either root or sudo user with access to run admin commands. I'll also provide examples for using the mkfs command effectively. In this tutorial, I will discuss generally what a file system is. You can also use the mkfs command in the following fashion. You can think of mkfs as a command line tool for formatting a disk into a specific filesystem. The command is commonly used for managing storage devices in Linux. The letters in mkfs stand for "make file system".
