How to view the type of mounted file system in Linux

How to view the type of mounted file system in Linux

Preface

As you know, Linux supports many file systems, such as ext4, ext3, ext2, sysfs, securityfs, FAT16, FAT32, NTFS, etc. The most used file system is ext4. Have you ever wondered what type of file system your Linux system is using? Have you ever had any doubts? Don't worry! We will help you. This guide will explain how to view the type of mounted filesystems in Unix-like operating systems.

View the type of mounted file systems in Linux

There are many ways to check the type of mounted filesystems in Linux, below I will show you 8 different methods. So let’s get started now!

Method 1 – Using findmnt command

This is the most commonly used method to find out the file system type. The findmnt command will list all mounted file systems or search for a specific file system. The findmnt command can search in the files /etc/fstab, /etc/mtab, or /proc/self/mountinfo.

findmnt comes pre-installed on most Linux distributions as it is a part of the util-linux package. If the findmnt command is not available, you can install this package. For example, you can install the util-linux package on Debian based systems using the following command:

$ sudo apt install util-linux

Next, let's look at how to use findmnt to find out which file systems are mounted.

If you just type findmnt command without any parameters or options, it will list all the mounted file systems in a tree format as shown below.

$ findmnt

Sample output:


As you can see, findmnt displays the target mount point ( TARGET ), source device ( SOURCE ), file system type ( FSTYPE ), and related mount options ( OPTIONS ), such as whether the file system is read-write or read-only. Taking my system as an example, my root (/) file system type is EXT4.

If you don't want to display the output in a tree view, you can use the -l option to display the output in a plain text view:

$ findmnt -l 

You can also use the -t option to list specific types of file systems, such as the ext4 file system type shown below:

$ findmnt -t ext4
TARGET SOURCE FSTYPE OPTIONS
/ /dev/sda2 ext4 rw,relatime,commit=360
└─/boot /dev/sda1 ext4 rw,relatime,commit=360,data=ordered

findmnt can also generate df-type output using the command

$ findmnt --df

or

$ findmnt -D

Sample output:

SOURCE FSTYPE SIZE USED AVAIL USE% TARGET
dev devtmpfs 3.9G 0 3.9G 0% /dev
run tmpfs 3.9G 1.1M 3.9G 0% /run
/dev/sda2 ext4 456.3G 342.5G 90.6G 75% /
tmpfs tmpfs 3.9G 32.2M 3.8G 1% /dev/shm
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
bpf bpf 0 0 0 - /sys/fs/bpf
tmpfs tmpfs 3.9G 8.4M 3.9G 0% /tmp
/dev/loop0 squashfs 82.1M 82.1M 0 100% /var/lib/snapd/snap/core/4327
/dev/sda1 ext4 92.8M 55.7M 30.1M 60% /boot
tmpfs tmpfs 788.8M 32K 788.8M 0% /run/user/1000
gvfsd-fuse fuse.gvfsd-fuse 0 0 0 - /run/user/1000/gvfs

You can also display the file system type for a specific device or mount point.

To view a specific device:

$ findmnt /dev/sda1
TARGET SOURCE FSTYPE OPTIONS
/boot /dev/sda1 ext4 rw,relatime,commit=360,data=ordered

View a specific mount point:

$ findmnt /
TARGET SOURCE FSTYPE OPTIONS
/ /dev/sda2 ext4 rw,relatime,commit=360

You can even check the type of filesystem a particular tag is:

$ findmnt LABEL=Storage

For more details, please refer to its man page.

$ man findmnt

The findmnt command is sufficient to complete the task of checking the type of mounted file systems in Linux. This command was created for this specific task. However, there are other ways to check the file system type, if you are interested, please continue reading.

Method 2 – Using blkid command

The blkid command is used to find and print the properties of block devices. It is also part of the util-linux package, so you don't have to install it.

To view the type of a file system using the blkid command, run:

$ blkid /dev/sda1

Method 3 – Using df Command

In Unix-like operating systems, the df command is used to report the disk space usage of the file system. To see the types of all mounted file systems, just run:

$ df -T

Sample output:


For more details about the df command, refer to the following guide.

df command tutorial for beginners

You can also refer to its man manual:

$ man df

Method 4 – Using the file command

The file command can determine the type of a specific file, even if the file has no file extension.

Run the following command to find out the file system type of a specific partition:

$ sudo file -sL /dev/sda1
[sudo] password for sk:
/dev/sda1: Linux rev 1.0 ext4 filesystem data, UUID=83a1dbbf-1e15-4b45-94fe-134d3872af96 (needs journal recovery) (extents) (large files) (huge files)

Check out its man page for more details:

$ man file

Method 5 – Using fsck command

The fsck command is used to check the health of a file system or to repair it. You can check the file system type of a partition by passing the partition name as an argument to fsck as follows:

$ fsck -N /dev/sda1
fsck from util-linux 2.32
[/usr/bin/fsck.ext4 (1) -- /boot] fsck.ext4 /dev/sda1

If you want to know more, please check its man page:

$ man fsck

Method 6 – Using fstab command

fstab is a file that contains static information about the file system. This file usually contains information such as the mount point, file system type, and mount options.

To check the type of a file system, just run:

$ cat /etc/fstab 

For more details, see its man page:

$ man fstab

Method 7 – Using lsblk Command

The lsblk command can display device information.

To display information about mounted file systems, just run:

$ lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
loop0 squashfs /var/lib/snapd/snap/core/4327
sd
├─sda1 ext4 83a1dbbf-1e15-4b45-94fe-134d3872af96 /boot
├─sda2 ext4 4d25ddb0-5b20-40b4-ae35-ef96376d6594 /
└─sda3 swap 1f8f5e2e-7c17-4f35-97e6-8bce7a4849cb [SWAP]
sr0

For more details, please refer to its man page:

$ man lsblk

Method 8 – Using the mount command

mount is used to mount local or remote file systems on Unix-like systems.

To view the type of file system using the mount command, do the following:

$ mount | grep "^/dev"
/dev/sda2 on / type ext4 (rw,relatime,commit=360)
/dev/sda1 on /boot type ext4 (rw,relatime,commit=360,data=ordered)

For more details, please refer to its man page:

$ man mount

Alright, now you know 8 different Linux commands to check the type of mounted Linux filesystems. If you know of other commands to accomplish the same task, please let me know in the comment section below and I will confirm and update this tutorial accordingly.

More exciting content will be presented soon, please stay tuned!

via: https://www.ostechnix.com/how-to-find-the-mounted-filesystem-type-in-linux/

Author: SK Topic: lujun9972 Translator: FSSlc Proofreader: wxy

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM.

You may also be interested in:
  • Summary of Linux partition file system type
  • Linux View File System Type Example Method

<<:  Install and deploy java8 and mysql under centos7

>>:  A record of the pitfalls of the WeChat applet component life cycle

Recommend

Steps of an excellent registration process

For a website, it is the most basic function. So l...

3 ways to correctly modify the maximum number of connections in MySQL

We all know that after the MySQL database is inst...

About ROS2 installation and docker environment usage

Table of contents Why use Docker? Docker installa...

Do you know how to use mock in vue project?

Table of contents first step: The second step is ...

How to set up vscode remote connection to server docker container

Table of contents Pull the image Run the image (g...

Summary of MySQL string interception related functions

This article introduces MySQL string interception...

How to use React forwardRef and what to note

Previously, react.forwardRef could not be applied...

JavaScript simulation calculator

This article shares the specific code of JavaScri...

Historical Linux image processing and repair solutions

The ECS cloud server created by the historical Li...

MySql 5.6.35 winx64 installation detailed tutorial

Note: There was no error in the project startup d...

Nginx domain forwarding usage scenario code example

Scenario 1: Due to server restrictions, only one ...

Introduction to the use of anchors (named anchors) in HTML web pages

The following information is compiled from the Int...

Solution to 404 Problem of Tomcat Installation in Docker

Find the containerID of tomcat and enter the toma...

How to solve the problem that Seata cannot use MySQL 8 version

Possible reasons: The main reason why Seata does ...

Example of how to check the capacity of MySQL database table

This article introduces the command statements fo...