9 Methods To Check File System Type In Linux (Ext2, Ext3 or Ext4)

As we already knows, in Linux, everything is configured as a file. This includes not only text files, images and compiled programs, directories, partitions and hardware device drivers, etc,.

Each filesystem contains two control block, one holds information about that filesystem. The other blocks in the filesystem are inodes (Metadata), which contain information about individual files and directory (File name, File types, Permission, Owner name, Group name, Size, Time stamps, Deletion time, hard link and soft link, location, etc.,.)

Inode number also called as index number, it contains above parameters.

There are many Linux filesystem types available like ext, ext2, ext3, ext4, hpfs, iso9660, JFS, minix, msdos, ncpfs nfs, ntfs, proc, Reiserfs, smb, sysv, umsdos, vfat, XFS, xiafs, etc.,.

A week ago, we have added new hard drive to one of our client server and successfully mounted. While mounting a hard drive we need to mention the file system type which already present in system. I have tried few commands which i already know to get the details about the file system type. So, finally i decided to prepare this as an article to help others to easily find the filesystem type.

I did a small google search before posting this article to add more method which i don’t know. In this article we will show you, Nine ways to get a filesystem type in Linux.

Method-1 : Using df Command

df command stands Disk Filesystem that provides disk space usage information of your file systems. Use -T option with df command to get a filesystem type.

# df -khT
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/sda3      ext4    99G   22G   73G  23% /
tmpfs          tmpfs  1.9G     0  1.9G   0% /dev/shm
/dev/sda1      ext4   477M  128M  325M  29% /boot
/dev/sda2      ext4   295G  166G  115G  60% /home
/usr/tmpDSK    ext3   3.6G   73M  3.4G   3% /tmp

Method-2 : Using mount Command

The mount command mounts a storage device or filesystem, making it accessible and attaching it to an existing directory structure.

# mount | grep "/dev"
/dev/sda3 on / type ext4 (rw,usrjquota=quota.user,jqfmt=vfsv0)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
/dev/sda2 on /home type ext4 (rw,usrjquota=quota.user,jqfmt=vfsv0)
/usr/tmpDSK on /tmp type ext3 (rw,noexec,nosuid,loop=/dev/loop0)

Method-3 : Get A Details From /etc/fstab File

Just print the /etc/fstab file on terminal to identify your Linux File System Type. It contains mount point name, fillesystem type, mount options.

# cat /etc/fstab

UUID=24263d9b-96f1-4b4c-a4b1-e84a91af31d1       /       ext4    usrjquota=quota.user,jqfmt=vfsv0        1       1
UUID=f21edf29-e9d2-45d0-a1bf-f7c0a6d6deab /boot                   ext4    defaults        1 2
UUID=7e87d2bd-af20-482f-a935-bebc5ef09dad       /home   ext4    usrjquota=quota.user,jqfmt=vfsv0        1       2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
UUID=e9ac2ab4-56f2-48ad-a7aa-2aca8bd35c0a  none  swap  sw 0  0
/usr/tmpDSK             /tmp                    ext3    defaults,noauto        0 0

Method-4 : Using fsck Command

fsck is used to check and optionally repair one or more Linux filesystems. Use -N option with fsck to print the filesystem type information instead of filesystem check (Don’t execute and just show output).

# fsck -N /dev/sda1
fsck from util-linux-ng 2.17.2
[/sbin/fsck.ext4 (1) -- /boot] fsck.ext4 /dev/sda1

# fsck -N /dev/sda2
fsck from util-linux-ng 2.17.2
[/sbin/fsck.ext4 (1) -- /home] fsck.ext4 /dev/sda2

# fsck -N /dev/sda3
fsck from util-linux-ng 2.17.2
[/sbin/fsck.ext4 (1) -- /] fsck.ext4 /dev/sda3

Method-5 : Using file Command

file command used to determine file type. Use -s option with file to print the filesystem type information.

# file -sL /dev/sda1
/dev/sda1: Linux rev 1.0 ext4 filesystem data (needs journal recovery) (extents) (huge files)

# file -sL /dev/sda2
/dev/sda2: Linux rev 1.0 ext4 filesystem data (needs journal recovery) (extents) (large files) (huge files)

# file -sL /dev/sda3
/dev/sda3: Linux rev 1.0 ext4 filesystem data (needs journal recovery) (extents) (large files) (huge files)

Method-6 : Using parted Command

parted is a program to manipulate disk partitions. It supports multiple partition table formats, including MS-DOS and GPT. Use -l option to lists partition layout on all block devices.

# parted -l
Model: Msft Virtual Disk (scsi)
Disk /dev/sda: 429GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos

Number  Start   End    Size   Type     File system  Flags
 1      1049kB  525MB  524MB  primary  ext4         boot
 2      525MB   322GB  321GB  primary  ext4
 3      322GB   429GB  107GB  primary  ext4

Method-7 : Using lsblk Command

lsblk lists information about all available or the specified block devices. The lsblk command reads the sysfs filesystem and udev db to gather information.

# lsblk -f
NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
loop0  ext3         2a681ef6-4566-4205-9446-4e56c53272e8 /tmp
├─sda1 ext4         f21edf29-e9d2-45d0-a1bf-f7c0a6d6deab /boot
├─sda2 ext4         7e87d2bd-af20-482f-a935-bebc5ef09dad /home
└─sda3 ext4         24263d9b-96f1-4b4c-a4b1-e84a91af31d1 /

Method-8 : Using blkid Command

The blkid program is the command-line interface that locate/print block device information (e.g. filesystem or swap).

# blkid /dev/sda1
/dev/sda1: UUID="f21edf29-e9d2-45d0-a1bf-f7c0a6d6deab" TYPE="ext4"

# blkid /dev/sda2
/dev/sda2: UUID="7e87d2bd-af20-482f-a935-bebc5ef09dad" TYPE="ext4"

# blkid /dev/sda3
/dev/sda3: UUID="24263d9b-96f1-4b4c-a4b1-e84a91af31d1" TYPE="ext4"

Method-9 : Using cfdisk Command

cfdisk is a curses-based program for partitioning any block device. It display or manipulate a disk partition table information.

# cfdisk 
                                 Disk: /dev/sda
               Size: 40 GiB, 42949672960 bytes, 83886080 sectors
                       Label: dos, identifier: 0x6ad96b19

    Device       Boot      Start       End  Sectors Size Id Type
>>  /dev/sda1    *          2048  79691775 79689728  38G 83 Linux               
    /dev/sda2           79693822  83884031  4190210   2G  5 Extended
    └─/dev/sda5         79693824  83884031  4190208   2G 82 Linux swap / Solaris

 │ Partition type: Linux (83)                                                 │
 │     Attributes: 80                                                         │
 │     Filesystem: ext4                                                       │
 │Filesystem UUID: a0ee5533-e698-4359-9ddf-9ccf8679b5ec                       │
 │     Mountpoint: / (mounted)                                                │
     [Bootable]  [ Delete ]  [  Quit  ]  [  Type  ]  [  Help  ]  [  Write ]
     [  Dump  ]

                  Quit program without writing partition table

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...