Every object in a Linux computer is considered a file. A Linux file system is an organization that is used to store and manage files on a storage device. The storage device is logically divided using the file system to keep different types of files arranged for effective search, access, deletion, and modification. Linux supports various file systems, including ext2, ext3, and ext4.
In this tutorial, we will learn how to show file system type in Linux. We can determine it using different methods.
1. Using df - T Command
The df command, also known as disk file system type, in Linux is used to check the disk usage on a storage device. This command-line utility is pre-installed on most of the major Linux operating system distributions. By default, the df command displays only the available and used disk space, but you can use the -T flag to display the file system of all the storage devices that are mounted:
The df command in this output shows the following information:
- Filesystem – name of the currently mounted partition or the storage device.
- Type – storage device or partition file system types.
- Size – total size of the mounted partition or storage device.
- Used – consumed disk space of the mounted partition or storage device.
- Avail – amount of available disk space of the mounted partition or storage device.
- Use% – percentage of used disk space in the mounted partition or storage device.
- Mounted on – name of the directory where the partition or storage device is mounted.
To display the metadata of a specific storage device or partition, specify the partition name with the df command. For example, to check the FS of the root partition, type:
df -Th /
2. Using lsblk -fs Command
To identify the filesystem type -fs option with lsblk:
In this output, we can see the partition name, FS type, file system version, label, disk ID, available disk size, and usage percentage.
3. Using mount | grep <disk-path>
The primary use of the mount command is to load a file system or a storage device on a Linux system. The mount command also makes the FS or storage device accessible and attaches them into the directory structure. You can also use this command for mounting a remote Linux FS and ISO images.
Run the mount command without any arguments to print information about the Linux partitions including the file system:
mount | grep “/dev/sda5”
4. Using fsck -N <device-path>
The fsck command checks Linux file system for any errors and repairs them, if specified. This command can also be used to print the type of the FS of specified storage device or partitions. If you do not want to check of the FS errors, then use the -N flag.
Use the following fsck command to check the Linux file system type on the specified partition:
fsck -N /dev/sda5
This output shows the fsck command-line utility version and the FS type as ext4.
5. Using blkid Command
The blkid command retrieves the specified block devices properties and prints them. This tool is preinstalled on most modern Linux operating system distributions. You can use this command to identify file system of every mounted and unmounted disk partition. Specify the disk partition name as the blkid command argument for which you want to identify the file system:
This output has the following fields:
- Name – The disk partition name, for example /dev/sda1.
- UUID – The Universally Unique Identifier (UUID) of the disk FS.
- BLOCK_SIZE – The size of the disk blocks on the specified partition.
- TYPE – Type of the FS, for example ext4.
- PARTUUID – The Universally Unique Identifier (UUID) of the partition.
Use the blkid command without any arguments to display block device properties of all mounted and unmounted partitions.
6. Using file -sL Command
The file command-line utility is preinstalled on all major Linux operating system distributions. This command can be used to check the type for a Linux file and because every partition or device is considered as a file in Linux and thus you can use this command to determine the type of the storage device or partition file system. The following example shows you how to check the FS of the disk partition sda5:
sudo file -sL /dev/sda5
You must use the sudo command for checking root partition permissions. The output of the file command shows that the /dev/sda5 partition is using the ext4 file system. The file command shows the file type, blocks and character files are read by using the -s flag, and the -L option enables symlinks.
7. Looking /etc/fstab File
Linux stores file system information, such as FS type, mount point, and mount options, in a static file known as /etc/fstab. Every storage device or partition has an entry in the /etc/fstab file to automatically mount the storage device at the boot time. Read the contents of this file to check the type of the file system of your partition or storage device.
This output shows the FS mount point as root, FS as ext4, UUID, and other information.
The /etc/fstab file will not contain an entry of the partitions or storage devices that are not configured to automatically mount at the boot time.
8. Using lfs Tool
The lfs command in Linux lists file systems when used without using any options. It displays output in a tabular format, which is very easy to read. However, lfs is not preinstalled in most Linux operating system distributions and you must manually install it before you can use this command to check the FS type.
You can install lfs using precompiled libraries following the below steps:
1. Download the binaries from the release page:
2. Extract the Zip file:
unzip -q ~/lfs_0.5.1.zip
3. Move the lfs executable files to the $PATH environment variable:
sudo mv ~/build/lfs /usr/local/bin/
After the installation is complete, try running the lfs command to check the file system type and other partition information. For example, the following commands display all mounted file systems:
The default lfs output shows file systems that are backed by block storage devices that look like the real disks. To list FS for all the storage devices, use the -a option:
In this tutorial, we learned how to determine the file system type in Linux using different commands. The commands listed in this tutorial are originally used for different operations, but you can use all of them to check disk storage metadata type either using with or without options. You should try these examples to better understand Linux file system structure, storage devices, storage space, and file system type.