How to Determine the File System Type in Linux (Ext2, Ext3 or Ext4)?

Operating SystemLinuxMCA

The file systems in Linux can be of different types. They support different file sizes and some mechanism like journaling etc. Also different types of file systems are supported by different Linux Kernel systems. So for the devices which are available as memory in the Linux System, we can determine their file types by using the following commands.

Using lsblk

This command dispalys all the attached divices as well as their file types and partitions.

$ lsblk -f

Running the above code gives us the following result −

NAME FSTYPE LABEL UUID MOUNTPOINT
sr0
sda
├─sda2
├─sda5 swap 02a54ace-c5c2-41cf-a679-acd9b460ee79 [SWAP]
└─sda1 ext4 ae7c051f-451b-45ad-80a3-347c70a9de5e /

Using file

It gives the disk file system type.

$ sudo file -sL /dev/sda1
[sudo] password for ubuntu:

Running the above code gives us the following result −

/dev/sda1: Linux rev 1.0 ext4 filesystem data, UUID=ae7c051f-451b-45ad-80a3-347c70a9de5e (needs journal recovery) (extents) (large files) (huge files)

Using fsck

Though fsck is mostly used to repair the file system, it also checks the file types.

$ fsck -N /dev/sda1

Running the above code gives us the following result −

fsck from util-linux 2.27.1
[/sbin/fsck.ext4 (1) -- /] fsck.ext4 /dev/sda1

Looking into /etc/fstab

This is a file which contains the details on mount points,file system types etc. We just have to use the cat command to get it’s content.

cat /etc/fstab

Running the above code gives us the following result −

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=ae7c051f-451b-45ad-80a3-347c70a9de5e / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=02a54ace-c5c2-41cf-a679-acd9b460ee79 none swap sw 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0

Using df

The df command with the option of –Th gives a very detailed view of the file types data along with percentage usage and mount point details.

$ df -Th

Running the above code gives us the following result −

Filesystem Type Size Used Avail Use% Mounted on
udev devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 393M 12M 382M 3% /run
/dev/sda1 ext4 19G 4.8G 13G 28% /
tmpfs tmpfs 2.0G 420K 2.0G 1% /dev/shm
tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
tmpfs tmpfs 393M 80K 393M 1% /run/user/1000
raja
Published on 03-Jan-2020 06:36:36
Advertisements