determine file system type in linux

How to Determine File System Type in Linux

Linux supports different types of file systems. Each file system offers something different in addition to the common features offered by most file systems. Also different kernel systems support different file systems. Sometimes it may be necessary to find out the file system used by various disks and even devices. In this article, we will look at how to determine file system type in Linux. There are various commands to do this. We will look at them one by one.


How to Determine File System Type in Linux

Here are the different commands to find out the file system type in Linux. You can use them on a disk partition, or device as per your requirement.


1. Using lsblk

The following command displays file system of all devices attached to your system.

$ lsblk -f
NAME    FSTYPE  LABEL           UUID                                 MOUNTPOINT
loop1   squashf                                                      /snap/amazo
loop2   squashf                                                      /snap/core/
loop3   squashf                                                      /snap/core1
loop4   squashf                                                      /snap/amazo
loop5   squashf                                                      /snap/core/
loop6   squashf                                                      /snap/core1
xvda
└─xvda1 ext4    cloudimg-rootfs 651cda91-e465-4685-b697-67aa07181279 /


2. Using file

You may also use file command to get file system type of partition or device. Here is an example.

$ sudo file -sL /dev/sda1
[sudo] password for ubuntu:
/dev/sda1: Linux rev 1.0 ext4 filesystem data, UUID=ae7c051f-451b-45ad-80a3-347c70a9de5e (needs journal recovery) (extents) (large files) (huge files)


3. Using fsck

You can also use fsck to get file system type, although it is generally used to repair file system.

$ fsck -N /dev/sda1
fsck from util-linux 2.31.1
[/sbin/fsck.ext2 (1) -- /dev/sda1] fsck.ext2 /dev/sda1


4. Using /etc/fstab

You can also view /etc/fstab file to view file system details including its type. It also displays other details like mount points, etc.

$ cat /etc/fstab
LABEL=cloudimg-rootfs   /        ext4   defaults,discard        0 0


5. Using df

df command is generally used to get disk usage. It can also be used to get details about the file system types of all disk partitions and devices. Here is an example.

$ df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs  979M     0  979M   0% /dev
tmpfs          tmpfs     199M  788K  198M   1% /run
/dev/xvda1     ext4      7.7G  6.0G  1.8G  78% /
tmpfs          tmpfs     993M     0  993M   0% /dev/shm
tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs          tmpfs     993M     0  993M   0% /sys/fs/cgroup
/dev/loop1     squashfs   34M   34M     0 100% /snap/amazon-ssm-agent/3552
/dev/loop2     squashfs  100M  100M     0 100% /snap/core/11316
/dev/loop3     squashfs   56M   56M     0 100% /snap/core18/2074
/dev/loop5     squashfs  100M  100M     0 100% /snap/core/11420
/dev/loop4     squashfs   25M   25M     0 100% /snap/amazon-ssm-agent/4046
/dev/loop6     squashfs   56M   56M     0 100% /snap/core18/2128
tmpfs          tmpfs     199M     0  199M   0% /run/user/1000

In this article, we have learnt several useful commands to easily get file system type of mounted disks and devices in Linux.

Also read:

How to Password Protect File in Linux
How to Block or Disable User Login in Linux
How to Check Kernel Version in Linux
How to Create CSR for Wildcard SSL Certificate
How to Remove Unused Kernels in Ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *