How to Determine the File System Type in Linux?

Linux OS stores and manages the data on disk or partition using a hierarchical structure called “Filesystem”. It includes files, directories, and related pieces of information. The main objective of the Linux file system is to arrange the file/directory on disk storage and manage the file information like the file name, creation date, file size, and much more.

Furthermore, there are different types of  Linux file systems, such as “ext3”, “ext4”, “FAT”, “XFS”, and much more. These file systems can be easily viewed using Linux’s built-in command line tools.

This guide elaborates on possible ways to determine the file system type in Linux. The guidelines of this guide are written below:

Method 1: Use the “df” Command to Check File System Type

The “df” is the “disk free” command that generally shows the file system information such as total and available space in the disk. It can also display the file system type of disk partitions and all the mounted storage devices.

For this purpose, execute the “df” command followed by the “-T” flag to print the file system type and “-h” to display the file size in human-readable format:

$ df -Th

In the current system “Ubuntu 22.04”, the  “/dev/sda3” has “ext4” while the  “/dev/sda2” partition has “vfat” file system type.

Tip: The user can also check only the partitions and the physical storage devices’ file system type by hiding all other parameters in the following way:

$ df -Th -x squashfs -x tmpfs -x devtmpfs

Now the output looks much better as compared to the previous one.

Method 2: Use the “lsblk” Command to Check File System Type

The “lsblk” stands for “list block devices” command that is utilized to get the details about the block devices except for RAM  in a tree format. It is generally pre-installed into most Linux distributions with the “util-Linux” package.

It offers the “-f” option to display the file system type of mounted storage devices and partitions in the column “FSTYPE” as shown below:

$ lsblk -f

Here, the above output also displays the loop devices’ information. To get the clear output of only the storage devices and partition, use the following command:

$ lsblk -f -e7

The above command has hidden information regarding all loops and displays only the partition information, especially their file system types highlighted in the terminal.

Method 3: Use the “fsck” Command to Check File System Type

The “fsck” is the “File System Consistency Check” Linux utility that identifies the errors, generates their reports, and repairs them. The error may be like partitions not being mounted, failing to boot, and many others.

In this method, the “-N” flag prints the “fsck” command status without the execution of any action. It also displays the file system type as an extension with the “fsck” command as shown in the image:

$ fsck -N /dev/sda1 $ fsck -N /dev/sda2 $ fsck -N /dev/sda2

The output of the above commands displays all three partitions file system types of the disk “/dev/sda”.

Method 4: Use the “file” Command to Check the File System Type

The main objective of the “file” Linux command line tool is to identify the file type of all the available files. It can also determine the file system type of the storage devices and partitions, as everything in Linux is considered a file.

To perform this task, the combination of “-s” and “-L” arguments of the “file” command is used that displays the special file system type(partitions) having file type MIME i.e., ‘text/plain; charset=us-ascii’:

$ sudo file -sL /dev/sda3

The above command displays the partition “/dev/sda3/” file system type that is “ext4”.In the same way, the user can find other partition file system types.

Method 5: Use the “mount” Command to Check File System Type

The “mount” command generally mounts the file system located in a device in a big tree format rooted at “/(forward slash)”. It also prints the file system type of partitions and all the mounted storage devices in the “/etc/mtab” file.

Execute the “mount” command with the “grep” to filter the filesystem type of all the partitions in the following way:

$ mount |grep “^/dev”

The output displays the “/dev/sda” disk partitions with file system type “ext4” and “vfat”.

Method 6: Use the “blkid” Command to Check File System Type

The “blkid” stands for “Block Identification” command that lists down the content of the audible block devices having attributes “UUID(Universally Unique Identifier)”, “BLOCK_SIZE(in bytes)” “TYPE(file system type)”, “LABEL (volume label)”:

To check the file system type of the mounted storage devices and partitions use the “blkid” command in the following way:

$ blkid /dev/sda3

Here the above command displays that the partition “/dev/sda3” uses the file system type “ext4”. The same procedure is followed for other partitions.

Method 7: Use the “fstab” File to Check File System Type

The “/etc/fstab” static file holds the information of the storage devices/partitions that are automatically mounted during the boot time. To check the file system type of partitions or the mounted storage device, use the “cat” command to read this file content in this way:

$ cat /etc/fstab

The output displays that partitions “/dev/sda3” use “ext4” and “/dev/sda2” use “vfat” file system type associated with their “UUID”.

Conclusion

Linux offers the pre-installed “df”, “lsblk”, and “fsck” commands to determine the file system type of the available mounted storage devices or partitions. The “file”, “mount”, and “blkid” commands are also useful to perform this task. In addition, the “fstab” file contains all the information regarding automatically mounted devices, including tier file system types. This guide has enlisted all the possible ways to determine the file system type in Linux.