Determining the filesystem type in Linux can be useful in various scenarios, such as when you want to mount a filesystem, when you want to create a new filesystem, or when you want to format a disk. There are several ways to determine the filesystem type in Linux, such as using the df, mount, or the lsblk command. In this article, we will explore these different ways to determine the filesystem type in Linux.
There are several ways to determine the filesystem type in Linux. Some of the most common ways are:
Method 1: Using the `lsblk`
command
The `lsblk`
command is a command-line utility that displays information about the block devices on your system, including the filesystem type. To display the filesystem type of a particular block device, you can use the -o option with the lsblk command to specify the information you want to display. For example, to display the filesystem type of the `/dev/sda`
block device, you can use the following command:
lsblk -o PATH,FSTYPE,MOUNTPOINT /dev/sda
This will display the filesystem type of the `/dev/sda` block device.
Output:PATH FSTYPE MOUNTPOINT /dev/sda /dev/sda1 /dev/sda2 vfat /boot/efi /dev/sda3 ext4 /
To get the details of the specific device like: `/dev/sda3`
.
lsblk -o FSTYPE /dev/sda3
You can also remove the header section from the result with `--noheadings`
option. This is helpful for writing the shell scripts.
FS_TYPE=`lsblk -o FSTYPE /dev/sda3 --noheadings`
echo ${FS_TYPE}
Method 2: Using the `df`
command
The `df`
command is a command-line utility that displays information about the filesystems on your system, including the filesystem type. To display the filesystem type of a particular filesystem, you can use the `-T` option with the df command. For example, to display the filesystem type of the `/` filesystem, you can use the following command:
df -T /
This will display the filesystem type of the / filesystem, as well as other information about the filesystem, such as the total size, used space, and available space.
Output:Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/sda3 ext4 22010352 10316820 10550136 50% /
Method 3: Using the `mount`
command
The mount command is a command-line utility that displays information about the filesystems that are currently mounted on your system, including the filesystem type. To display the filesystem type of a particular filesystem, you can use the mount command without any options. For example, to display the filesystem type of the / filesystem, you can use the following command:
mount
This will display a list of all the mounted filesystems on your system, along with their mount points and filesystem types.
I hope this helps! Let me know if you have any questions.
Conclusion
In conclusion, there are several ways to determine the filesystem type in Linux, such as using the `df` command, the `mount` command, and the `lsblk` command. These utilities provide different ways to display information about the filesystems on your system, including the filesystem type. Understanding how to use these utilities can be helpful in various scenarios when working with filesystems in Linux.