Check filesystem type in Linux

The purpose of this tutorial is to show several methods to check the filesystem type of a storage device in Linux.

We will show how a user can ascertain the type of filesystem for both mounted and unmounted partitions. See the various commands below to get started.

In this tutorial you will learn:

  • How to check filesystem type of a partition in Linux
Check filesystem type in Linux with various command examples
Check filesystem type in Linux with various command examples
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Check filesystem type




Use any of the following commands to detect the filesystem type of a partition on your own Linux system.

  1. It’s very easy to detect the filesystem type of a mounted partition with the df command and the -T (type) option.
    $ df -T
    Filesystem     Type     1K-blocks    Used Available Use% Mounted on
    udev           devtmpfs    986848       0    986848   0% /dev
    tmpfs          tmpfs       203296    1372    201924   1% /run
    /dev/sda5      ext4      40503552 8017120  30399264  21% /
    ...
    

    As seen in the output above, our /dev/sda5 partition is using the ext4 filesystem.

  2. We can use the file command to detect the filesystem type of an unmounted partition. You will need to specify the device file in your command. In this example, we’ll try this on /dev/sdb1 and /dev/sda1.
    # file -s /dev/sdb1 | cut -d , -f1
    /dev/sdb1: sticky Linux rev 1.0 ext3 filesystem data
    
    # file -s /dev/sda1 | cut -d , -f1
    /dev/sda1: sticky Linux rev 1.0 ext4 filesystem data
    

    From the above output, we can see that partition /dev/sda1 is of ext4 filesystem type, whereas /dev/sdb1 has ext3 filesystem type.

  3. Alternatively, we can use blkid command. Once again, specify the partition in your command.
    # blkid /dev/sdb1
    /dev/sdb1: UUID="57bbbdd1-14c0-4dab-96be-4542fa2fc862" SEC_TYPE="ext2" TYPE="ext3" 
    
    # blkid /dev/sda1
    /dev/sda1: UUID="60254c19-67c0-404b-9743-1b8b7f0b11cb" TYPE="ext4"
    

Conclusion




That’s all there is to it. In this tutorial, you saw how the df, file, and blkid commands can be used to detect the type of filesystem on a mounted or unmounted partition. These should be the only commands you will need to detect the type of filesystem on any Linux system.



Comments and Discussions
Linux Forum