Linux show file system type

10 basic & powerful commands to check file system type in Linux/Unix

Any operating system must be able to access and manage files on storage devices; however, the manner in which the files are organized on a storage device is actually set by the underlying filesystem.With Linux and Unix there are various filesystem types, so in this article I will share multiple commands and methods to check file system type in Linux and Unix.

Before we try to determine and check file system type, we must be familiar with the term «File System».

What is a FileSystem?

As you probably know, or at least can guess, hard drives are not monolithic entities with data simply spread haphazardly around the hard drive. Hard drives are organized into sectors and clusters. Data of any type is organized into files. Whether it is a document, image, spreadsheet, or even an executable program, it is a file. That file may be stored in one or more clusters.

Filesystems are responsible to organize, find, and work with those files that are on the hard drive. There are issues that any filesystem must address in order to handle files effectively.

The first issue occurs because many files are larger than a single sector or cluster. So, locating the entirety of a file on a hard drive is an issue that must be addressed. The operating system may need to check several clusters, not necessarily contiguous, to find a file.

Another problem is how to store the files in clusters and sectors. Also, a filesystem must address how to handle space left due to deleted or moved files.

Now since we know what is a File System, Let us start with the actual agenda of this article.

Commands to check file system type in Linux or Unix

1. blkid

blkid can determine the type of content (e.g. filesystem or swap) that a block device holds, and also the attributes (tokens, NAME=value pairs) from the content metadata (e.g. LABEL or UUID fields).

You can also create your own man page with a list of instructions for a script or a custom tool which you have created. In real time production environment it is always recommended to also create and release a man page for every script or tool we develop.

Читайте также:  Nfs server logs linux

You must execute blkid as root user without any directives and check » TYPE » field to check file system type of respective partition or device in Linux or Unix.

[root@centos-8 ~]# blkid /dev/mapper/rhel-root: UUID="0b5322d5-887d-4c03-9933-b75c2a1ca880" TYPE="ext4" /dev/sda2: UUID="pXZ2Iy-hwtF-mFH2-nbej-0Yz9-Py2O-AqLQNH" TYPE="LVM2_member" PARTUUID="fcbab19d-02" /dev/sdb1: UUID="1b3910d9-11a9-4f68-894e-47a51bd077a8" TYPE="crypto_LUKS" PARTUUID="09181a39-01" /dev/sda1: UUID="2b857500-a7cf-4ec4-8453-0ef636943d86" TYPE="ext4" PARTUUID="fcbab19d-01" /dev/sr0: UUID="2019-08-15-21-52-52-00" LABEL="CentOS-8-BaseOS-x86_64" TYPE="iso9660" PTUUID="3e04f576" PTTYPE="dos" /dev/mapper/rhel-swap: UUID="cd18aa4a-e2d3-423c-b120-7fef1b1d9aac" TYPE="swap"

With -t, —match-token NAME=value , you can search for block devices with tokens named NAME that have the value value, and display any devices which are found. Common values for NAME include TYPE , LABEL , and UUID

For example to list and check file system type for ext4 FS:

[root@centos-8 ~]# blkid -t TYPE=ext4 /dev/mapper/rhel-root: UUID="0b5322d5-887d-4c03-9933-b75c2a1ca880" TYPE="ext4" /dev/sda1: UUID="2b857500-a7cf-4ec4-8453-0ef636943d86" TYPE="ext4" PARTUUID="fcbab19d-01"

2. lsblk

lsblk lists information about all available or the specified block devices. lsblk command provides more information, better control on output formatting, easy to use in scripts and it does not require root permissions to get actual information.

[root@centos-8 ~]# lsblk --fs NAME FSTYPE LABEL UUID MOUNTPOINT sda ├─sda1 ext4 2b857500-a7cf-4ec4-8453-0ef636943d86 /boot └─sda2 LVM2_member pXZ2Iy-hwtF-mFH2-nbej-0Yz9-Py2O-AqLQNH ├─rhel-root ext4 0b5322d5-887d-4c03-9933-b75c2a1ca880 / └─rhel-swap swap cd18aa4a-e2d3-423c-b120-7fef1b1d9aac [SWAP] sdb └─sdb1 crypto_LUKS 1b3910d9-11a9-4f68-894e-47a51bd077a8 sr0 iso9660 CentOS-8-BaseOS-x86_64 2019-08-15-21-52-52-00 sr1

3. df

df is another popular and most used command to display the amount of disk space available on the file system containing each file name argument. If no file name is given, the space available on all currently mounted file systems is shown.

Using -T directive with df command you can print file system type of all the mounted file systems.

[root@centos-8 ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 2.4G 0 2.4G 0% /dev tmpfs tmpfs 2.4G 0 2.4G 0% /dev/shm tmpfs tmpfs 2.4G 8.6M 2.4G 1% /run tmpfs tmpfs 2.4G 0 2.4G 0% /sys/fs/cgroup /dev/mapper/rhel-root ext4 14G 9.2G 3.5G 73% / /dev/sda1 ext4 488M 129M 325M 29% /boot tmpfs tmpfs 479M 0 479M 0% /run/user/0

Alternatively you can specify a device with df command to check file system type of the respective device

# df -Th /boot /dev/sda1 ext4 488M 129M 325M 29% /boot

4. findmnt

findmnt will list all mounted filesystems or search for a filesystem. The findmnt command is able to search in /etc/fstab , /etc/mtab or /proc/self/mountinfo . If device or mountpoint is not given, all filesystems are shown.

Using —fstab directive, findmnt command will search in /etc/fstab and with -t it will limit the set of printed filesystems

[root@centos-8 ~]# findmnt --fstab -t ext4 TARGET SOURCE FSTYPE OPTIONS / /dev/mapper/rhel-root ext4 defaults /boot UUID=2b857500-a7cf-4ec4-8453-0ef636943d86 ext4 defaults

If used without any directive, findmnt command will give you long list of output with all bind mounts

[root@centos-8 ~]# findmnt -t ext4 TARGET SOURCE FSTYPE OPTIONS / /dev/mapper/rhel-root ext4 rw,rela ├─/boot /dev/sda1 ext4 rw,rela ├─/var/named/chroot/etc/localtime /dev/mapper/rhel-root[/usr/share/zoneinfo/Asia/Kolkata] │ ext4 rw,rela ├─/var/named/chroot/etc/named.root.key /dev/mapper/rhel-root[/etc/named.root.key] ext4 rw,rela ├─/var/named/chroot/etc/named.conf /dev/mapper/rhel-root[/etc/named.conf] ext4 rw,rela ├─/var/named/chroot/etc/named.rfc1912.zones /dev/mapper/rhel-root[/etc/named.rfc1912.zones] ext4 rw,rela ├─/var/named/chroot/etc/rndc.key /dev/mapper/rhel-root[/etc/rndc.key] ext4 rw,rela ├─/var/named/chroot/etc/crypto-policies/back-ends/bind.config │ /dev/mapper/rhel-root[/usr/share/crypto-policies/DEFAULT/bind.txt] │ ext4 rw,rela ├─/var/named/chroot/etc/protocols /dev/mapper/rhel-root[/etc/protocols] ext4 rw,rela ├─/var/named/chroot/etc/services /dev/mapper/rhel-root[/etc/services] ext4 rw,rela ├─/var/named/chroot/etc/named /dev/mapper/rhel-root[/etc/named] ext4 rw,rela ├─/var/named/chroot/usr/lib64/bind /dev/mapper/rhel-root[/usr/lib64/bind] ext4 rw,rela └─/var/named/chroot/var/named /dev/mapper/rhel-root[/var/named] ext4 rw,rela

5. file

file command is normally only attempts to read and determine the type of argument files. Specifying the -s option causes file to also read argument files which are block or character special files. This is useful for determining and to check file system types of the data in raw disk partitions, which are block special files

# file -s /dev/sda1 /dev/sda1: Linux rev 1.0 ext4 filesystem data, UUID=2b857500-a7cf-4ec4-8453-0ef636943d86 (needs journal recovery) (extents) (64bit) (large files) (huge files)

6. udevadm

udevadm command queries the udev database for device information stored in the udev database. It can also query the properties of a device from its sysfs representation to help creating udev rules that match this device.

Читайте также:  Usb to rj45 linux

Using —query you can query the database for the specified type of device data. The below command gives a long output so we will grep the required data to check file system type for our device /dev/sda1

# udevadm info --query=property /dev/sda1 | egrep "DEVNAME|ID_FS_TYPE" DEVNAME=/dev/sda1 ID_FS_TYPE=ext4

Some more commands and methods to determine filesystem type in Linux or Unix

Now above were some of the most used commands to check file system type but there are many other methods using which you can determine filesystem type

7. File /etc/fstab content

Normally all the devices we use are mounted via /etc/fstab file to make the mounting reboot persistent. So you can always refer /etc/fstab file to check file system type, for example:

# cat /etc/fstab /dev/mapper/rhel-root / ext4 defaults 1 1 UUID=2b857500-a7cf-4ec4-8453-0ef636943d86 /boot ext4 defaults 1 2 /dev/mapper/rhel-swap swap swap defaults 0 0

Here the first column of the file specifies the partition device path while the third column shows the file system type of the respective device.

8. File /etc/mtab content

Similar to /etc/fstab you can also refer /etc/mtab to get the list of currently mounted file system along with the file system type.

# grep root /etc/mtab /dev/mapper/rhel-root / ext4 rw,relatime 0 0

Here also the first column of the file specifies the partition device path while the third column shows the file system type of the respective device.

9. File /proc/mounts

Now /proc/mounts file refers /etc/mtab so this is not a new method but just another file which you can look into to check file system type in Linux or Unix.

10. mount command

Again, mount command will also refer /etc/mtab file to get the list of mounted file systems and can also help you determine file system type of individual devices.

# mount sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) devtmpfs on /dev type devtmpfs (rw,nosuid,size=2436780k,nr_inodes=609195,mode=755) securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime) tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)

Lastly I hope the methods and commands from the article to determine and check file system type on Linux and Unix was helpful. So, let me know your suggestions and feedback using the comment section.

Читайте также:  Arch linux обновление пакета

Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Источник

How to Show File System Type in Linux

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:

Showing filesystem type using df

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:

2. Using lsblk -fs Command

To identify the filesystem type -fs option with lsblk:

Источник

Оцените статью
Adblock
detector