Americas

  • United States
sandra_henrystocker
Unix Dweeb

Understanding Linux file system types

How-To
Apr 24, 20236 mins
Linux

Linux systems use a variety of file systems with very different strengths and benefits.

data files
Credit: Dell

You may not spend much time contemplating the characteristics of the file systems on your Linux system, but the differences between the various file system types can be both interesting and highly relevant. This article explains commands that you can use to verify your file system types and describes their differences.

Commands that report file system types

There are a number of Linux commands that will display file system types along with the file system names, mount points and such. Some will also display sizes and available disk space.

Using df -Th

The df command with the “T” (show file system type) and “h” (use human-friendly sizes) options provides a very useful look at the file systems on a Linux system. Here’s an example:

$ df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  4.0M     0  4.0M   0% /dev
tmpfs          tmpfs     2.9G     0  2.9G   0% /dev/shm
tmpfs          tmpfs     1.2G  1.7M  1.2G   1% /run
/dev/sda2      btrfs     111G   11G  100G  10% /
tmpfs          tmpfs     2.9G   56K  2.9G   1% /tmp
/dev/sda2      btrfs     111G   11G  100G  10% /home
/dev/sda1      ext4      974M  330M  577M  37% /boot
/dev/sdb1      ext4      427G   71G  334G  18% /apps
tmpfs          tmpfs     593M  128K  593M   1% /run/user/1000

Notice that the details include mount points, sizes, used and available space.

Using fsck

You can use the fsck (file system check) command to report on a particular file system as shown in the example below. This sample command shows that the /dev/sda1 disk partition contains an ext4 file system.

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

Using lsblk

The lsblk (list block devices) command displays information on block devices (storage devices that hold data in the form of blocks) – both hard drives and solid state drives. It provides file system type information along other data – the file system version, the UUID (unique identifier) and mount point, along with details on how much space is available and what percentage of the allocated space is in use.

$ lsblk -f /dev/sda1
NAME FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda1 ext4   1.0         417d867b-270d-4ceb-a3e1-58b9a5f5c4c4  576.8M    34% /boot

Using the mount command

The mount command below shows file system types for mounted file systems (5th string) along with many additional details.

$ mount | grep /dev
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=4096k,nr_inodes=131072,mode=755,inode64)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel,inode64)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
/dev/sda2 on / type btrfs (rw,relatime,seclabel,compress=zstd:1,ssd,space_cache,subvolid=257,subvol=/root)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel,pagesize=2M)
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime,seclabel)
/dev/sda2 on /home type btrfs (rw,relatime,seclabel,compress=zstd:1,ssd,space_cache,subvolid=256,subvol=/home)
/dev/sda1 on /boot type ext4 (rw,relatime,seclabel)
/dev/sdb1 on /apps type ext4 (rw,relatime,seclabel)

To view just a list of the file system types, use a command like this:

$ mount | grep "/dev" | awk '{print $5}' | sort | uniq
btrfs
devpts
devtmpfs
ext4
hugetlbfs
mqueue
tmpfs

Using the file command

The file command with the -sL options can be used to list details for the file system associated with a particular disk partition.

$ sudo file -sL /dev/sda1
/dev/sda1: Linux rev 1.0 ext4 file system data, UUID=417d867b-270d-4ceb-a3e1-58b9a5f5c4c4 (needs journal recovery) (extents) (64bit) (large files) (huge files)

File system types

Linux systems make use of a variety of file system types. Some were built to replace older file system types with faster and more reliable ones. Others serve some very particular purposes.

What is ext4?

The ext4 file system is the 4th generation ext file system. The first, ext, was implemented in April 1992 and was the first file system created specifically for the Linux kernel. It was the first implementation that used a virtual file system (VFS) and could handle file systems up to 2 gigabytes (GB) in size.

Since ext, the other extended file systems – ext2, ext3 and ext4 – were developed, each with improvements over its predecessor.

What is btrfs?

The btrfs file system is a “copy on write” (COW) file system. It is often pronounced “Better F S”. It implements advanced features with a focus on fault tolerance, self repair and painless administration.

What are tmpfs and devtmpfs?

Both tmpfs and devtmpfs file systems maintain content that is truly temporary. Both are file systems which keep all of their files in virtual memory. Everything is temporary in the sense that no files will be created on your hard drive. If you were to unmount such a file system, everything stored in it would be lost.

They may appear to be mounted file systems, but they are not. One purpose is to improve boot time.

A devtmpfs file system uses automated device nodes populated by the kernel each time the system boots.

What is hugetlbfs?

The hugetlbfs is an interface to the huge page capabilities of the underlying hardware. It allows the use of all huge page sizes supported by the hardware and kernel.

What is mqueue?

The mqueue file system type provides a lightweight buffer to temporarily store messages and endpoints that allow software components to connect to the queue in order to send and receive messages.

What is devpts?

The devpts file system mounted as /dev/pts provides pseudo-terminal support for tools like telnet and ssh. Look at its contents and you should see something like this:

$ ls -l /dev/pts
total 0
crw--w----. 1 shs  tty  136, 0 Apr  3 08:53 0
crw--w----. 1 shs  tty  136, 1 Apr 23 14:30 1
c---------. 1 root root   5, 2 Apr  3 08:07 ptmx

What is XFS?

XFS is a 64-bit file system and, at least in theory, can handle file systems as large as 8 exabytes. This is incredibly large. One exabyte equals one million terabytes. Oracle currently supports 100 terabytes, but this is still huge. Notice that I didn’t use the word “only”.

XFS provides for quick recovery, scalability and speed. It offers the benefits of a journaling file system without impacting performance. Journaling file systems keep track of changes not yet committed to the file system by recording the goals of those changes.

XFS is the default file system in RHEL. Because it lays out files as extents, it is less vulnerable to fragmentation than ext4. Red Hat recommends deploying XFS as your local file system unless there are specific reasons to do otherwise.

Wrap-up

The variety of file systems on Linux systems serve many different purposes and provide reliable and speedy responses to system operations.

sandra_henrystocker
Unix Dweeb

Sandra Henry-Stocker has been administering Unix systems for more than 30 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She lives in the mountains in Virginia where, when not working with or writing about Unix, she's chasing the bears away from her bird feeders.

The opinions expressed in this blog are those of Sandra Henry-Stocker and do not necessarily represent those of IDG Communications, Inc., its parent, subsidiary or affiliated companies.

More from this author