How to check if a file system type is used in Linux

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, you will learn how to determine which file system types are currently in use on your Linux system. You will explore different methods to achieve this, starting with using the df -T command to view mounted file systems and their types.

You will then learn how to list all supported file systems on your system by inspecting the /proc/filesystems file. Finally, you will examine the /etc/fstab file to understand how file systems are configured to be mounted automatically at boot time. By completing these steps, you will gain a comprehensive understanding of how to identify and understand the file systems in use on your Linux environment.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("Linux")) -.-> linux/BasicFileOperationsGroup(["Basic File Operations"]) linux(("Linux")) -.-> linux/SystemInformationandMonitoringGroup(["System Information and Monitoring"]) linux/BasicFileOperationsGroup -.-> linux/cat("File Concatenating") linux/SystemInformationandMonitoringGroup -.-> linux/df("Disk Space Reporting") subgraph Lab Skills linux/cat -.-> lab-558715{{"How to check if a file system type is used in Linux"}} linux/df -.-> lab-558715{{"How to check if a file system type is used in Linux"}} end

Check file systems with df -T

In this step, you will learn how to check the file systems on your Linux system using the df command. The df command is used to display the amount of disk space available on the file systems.

File systems are the way that data is organized and stored on a storage device, like a hard drive or SSD. Different file systems have different features and are used for different purposes.

To see the disk space usage and the type of file system, we will use the df command with the -T option. The -T option tells df to include the file system type in the output.

Open your terminal if it's not already open. Type the following command and press Enter:

df -T

You will see output similar to this:

Filesystem     Type     1K-blocks    Used Available Use% Mounted on
overlay        overlay   XXXXXXXX XXXXXXXX XXXXXXXX XX% /
tmpfs          tmpfs     XXXXXXXX XXXXXXXX XXXXXXXX XX% /dev
tmpfs          tmpfs     XXXXXXXX XXXXXXXX XXXXXXXX XX% /sys/fs/cgroup
/dev/vda1      ext4      XXXXXXXX XXXXXXXX XXXXXXXX XX% /etc/hosts
shm            tmpfs     XXXXXXXX XXXXXXXX XXXXXXXX XX% /dev/shm
tmpfs          tmpfs     XXXXXXXX XXXXXXXX XXXXXXXX XX% /run/secrets
tmpfs          tmpfs     XXXXXXXX XXXXXXXX XXXXXXXX XX% /proc/scsi
tmpfs          tmpfs     XXXXXXXX XXXXXXXX XXXXXXXX XX% /sys/firmware
/dev/vda1      ext4      XXXXXXXX XXXXXXXX XXXXXXXX XX% /home/labex/project

Let's break down the output:

  • Filesystem: The name of the file system.
  • Type: The type of the file system (e.g., overlay, tmpfs, ext4).
  • 1K-blocks: The total size of the file system in 1K blocks.
  • Used: The amount of space used on the file system.
  • Available: The amount of free space available.
  • Use%: The percentage of space used.
  • Mounted on: The directory where the file system is mounted (attached) to the file system hierarchy.

You can see different file system types like overlay, tmpfs, and ext4. ext4 is a common journaling file system for Linux. tmpfs is a temporary file system that resides in memory. overlay is often used in container environments like Docker.

Understanding file systems and how to check their usage is a fundamental skill in Linux system administration.

Click Continue to proceed to the next step.

List supported file systems in /proc/filesystems

In this step, you will learn how to find out which file systems are supported by your Linux kernel. This information is available in a special file located at /proc/filesystems.

The /proc directory is a virtual file system that provides information about processes and other system information. It's not stored on disk but is generated by the kernel in real-time.

To view the contents of the /proc/filesystems file, we can use the cat command. The cat command is used to display the content of files.

Type the following command in your terminal and press Enter:

cat /proc/filesystems

You will see a list of file systems, similar to this:

nodev   sysfs
nodev   rootfs
nodev   ramfs
nodev   bdev
nodev   proc
nodev   cgroup
nodev   cgroup2
nodev   cpuset
nodev   tmpfs
nodev   devtmpfs
nodev   configfs
nodev   debugfs
nodev   tracefs
nodev   securityfs
nodev   sockfs
nodev   pipefs
nodev   anon_inodefs
nodev   devpts
    ext3
    ext2
    ext4
nodev   hugetlbfs
nodev   pstore
nodev   mqueue
    vfat
nodev   fuse
nodev   fuseblk
nodev   fusectl
nodev   overlay
nodev   autofs
nodev   efivarfs
nodev   squashfs
nodev   ecryptfs
nodev   aufs
nodev   binfmt_misc
nodev   rpc_pipefs
nodev   nfsd
nodev   cifs
nodev   nfs
nodev   nfs4
nodev   ceph
nodev   cramfs
nodev   romfs
nodev   jffs2
nodev   udf
nodev   isofs
nodev   msdos
nodev   ntfs
nodev   hfsplus
nodev   hfs
nodev   qnx4
nodev   ufs
nodev   omfs
nodev   minix
nodev   hpfs
nodev   xfs
nodev   jfs
nodev   reiserfs
nodev   btrfs
nodev   nilfs2
nodev   f2fs
nodev   ubifs
nodev   ceph
nodev   coda
nodev   afs
nodev   9p
nodev   hostfs
nodev   fat
nodev   exfat
nodev   udf
nodev   isofs
nodev   msdos
nodev   ntfs
nodev   hfsplus
nodev   hfs
nodev   qnx4
nodev   ufs
nodev   omfs
nodev   minix
nodev   hpfs
nodev   xfs
nodev   jfs
nodev   reiserfs
nodev   btrfs
nodev   nilfs2
nodev   f2fs
nodev   ubifs
nodev   ceph
nodev   coda
nodev   afs
nodev   9p
nodev   hostfs
nodev   fat
nodev   exfat

Each line in this file represents a file system type that your kernel knows about. File systems listed with nodev are "virtual" file systems that don't operate on a block device (like a hard drive partition). Examples include proc, sysfs, and tmpfs. File systems without nodev (like ext4, vfat, ntfs) are typically used on block devices.

This file is a quick way to see the range of file systems your system can potentially work with.

Click Continue to move to the next step.

Inspect mounts in /etc/fstab

In this step, you will learn about the /etc/fstab file. This file is a configuration file that contains information about the file systems that are automatically mounted when the system boots up.

The name fstab stands for "file system table". It's a crucial file for defining how and where different storage devices and partitions are attached to the Linux file system hierarchy.

Each line in /etc/fstab describes a single mount point. Let's view the contents of this file using the cat command.

Type the following command in your terminal and press Enter:

cat /etc/fstab

You will see output similar to this:

## UNCONFIGURED FSTAB FOR BASE SYSTEM
## /etc/fstab: static file system information.
#
## Use 'blkid' to print the universally unique identifier for a
## device; this may be used with UUID= as a more robust way to name devices
## that works even if disks are added or removed. See fstab(5).
#
## <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/vda1       /etc/hosts      ext4    rw,relatime     0       0
/dev/vda1       /home/labex/project ext4    rw,relatime     0       0

The lines starting with # are comments and are ignored by the system. The other lines define the mount points. Each non-comment line has six fields:

  1. <file system>: The device or remote file system to be mounted (e.g., /dev/vda1).
  2. <mount point>: The directory where the file system will be mounted (e.g., /etc/hosts, /home/labex/project).
  3. <type>: The type of the file system (e.g., ext4).
  4. <options>: Mount options (e.g., rw for read-write, relatime for updating access times).
  5. <dump>: Used by the dump utility for backups (usually 0).
  6. <pass>: Used by fsck for checking file system integrity during boot (usually 0 for non-root file systems).

In this environment, you see entries for /etc/hosts and /home/labex/project mounted from /dev/vda1 with the ext4 file system type. This file is essential for ensuring that your system's file systems are correctly set up and available after a reboot.

You have now learned how to inspect the /etc/fstab file to understand how file systems are configured for automatic mounting.

Click Continue to complete this lab.

Summary

In this lab, you learned how to check the file systems used on your Linux system. You started by using the df -T command to display mounted file systems along with their types, such as overlay, tmpfs, and ext4, and their disk space usage. This command provides a quick overview of the file systems currently in use and where they are mounted in the file system hierarchy.

Next, you explored how to list all file system types supported by your Linux kernel by inspecting the /proc/filesystems file. Finally, you learned how to examine the /etc/fstab file to understand which file systems are configured to be mounted automatically at boot time, providing insight into the persistent file system configuration of the system.