The more hard drives are lying around and the more you use them, then it becomes more important to know how to unambiguously determine file system type without mounting it.


This utility is very useful to quickly determine used file systems on specified device.

Internal hard drive using GUID partition table.

$ sudo parted /dev/sda print
Model: ATA LITEON L8H-256V2 (scsi)
Disk /dev/sda: 256GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number  Start   End     Size    File system     Name  Flags
 1      1049kB  512MB   511MB   fat32                 boot, esp
 2      512MB   31.2GB  30.7GB  ext4
 3      31.2GB  248GB   217GB   ext4
 4      248GB   256GB   8193MB  linux-swap(v1)

External hard drive using MBR partitioning scheme.

$ sudo parted /dev/sdb print
Model: INTEL SS DSA2M080G2GC (scsi)
Disk /dev/sdb: 80.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number  Start   End     Size    Type      File system  Flags
 1      1049kB  256MB   255MB   primary   ext2         boot
 2      257MB   80.0GB  79.8GB  extended
 5      257MB   80.0GB  79.8GB  logical


This utility from util-linux package will print information about all available or the specified block devices
using sysfs file system and udev database to gather information.

Execute it to print information using tree-like format.

$ lsblk -f /dev/sda
NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
├─sda1 vfat         DA4C-5D7D                            /boot/efi
├─sda2 ext4         ff4db0d2-e659-4e1d-a7eb-f7ec49351ac8 /
├─sda3 ext4         375ddc04-190b-444d-85aa-907905fb4aa2 /home
└─sda4 swap         2c753483-f8ea-42ef-bbcd-a0c9dd2fc751 [SWAP]
$ lsblk -f /dev/sdb
NAME   FSTYPE      LABEL UUID                                 MOUNTPOINT
├─sdb1 ext2              763b1a31-0a41-453c-aebb-8f28e45b19db /media/milosz/763b1a31-0a41-453c-aebb-8f28e45b19db1
└─sdb5 crypto_LUKS       92e4fc6c-eac0-434e-9d4c-316449a0f122

Print determined file system information for the specified block devices.

$ lsblk -n -o FSTYPE /dev/sdb5

It can be easily used inside shell script using local variables.

$ lsblk -P -o NAME,FSTYPE /dev/sda1
NAME="sda1" FSTYPE="vfat"
$ (eval $(lsblk -P -o NAME,FSTYPE /dev/sda1); echo $NAME - $FSTYPE)
sda1 - vfat
You can use blkid utility to achieve the same results, so I will omit it this time.


This basic utility provides an option to determine the file system type of the data in specified raw disk partition.

$ sudo file -s /dev/sda3
/dev/sda3: Linux rev 1.0 ext4 filesystem data, UUID=375ddc04-190b-444d-85aa-907905fb4aa2 (needs journal recovery) (extents) (large files) (huge files)
$ sudo file -s /dev/sda4
/dev/sda4: Linux/i386 swap file (new style), version 1 (4K pages), size 2000127 pages, no label, UUID=2c753483-f8ea-42ef-bbcd-a0c9dd2fc751
$ sudo file -s /dev/sdb5
/dev/sdb5: LUKS encrypted file, ver 1 [aes, xts-plain64, sha1] UUID: 92e4fc6c-eac0-434e-9d4c-316449a0f122

As you can see, this utility provides very detailed information regarding file system type.