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
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
|Conventions||# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – 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.
- It’s very easy to detect the filesystem type of a mounted partition with the
dfcommand and the
$ 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/sda5partition is using the ext4 filesystem.
- We can use the
filecommand 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
# 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/sda1is of ext4 filesystem type, whereas
/dev/sdb1has ext3 filesystem type.
- Alternatively, we can use
blkidcommand. 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"
That’s all there is to it. In this tutorial, you saw how the
blkidcommands 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.