- The 35+ best Black Friday Nintendo Switch deals 2024
- Cisco unveils SD-WAN Configuration Catalog to streamline industrial deployments
- Best Black Friday TV deals 2024: 75+ expert-selected deals on QLED, OLED, & more
- Shopping for your kids this Black Friday? This is the best kids' device of 2024
- Australia Passes Groundbreaking Cyber Security Law
How to determine your Linux system’s filesystem types
Linux systems use a number of file system types – such as Ext, Ext2, Ext3, Ext4, JFS, XFS, ZFS, XFS, ReiserFS and btrfs. Fortunately, there are a number of commands that can look at your file systems and report on the type of each of them. This post covers seven ways to display this information.
To begin, the file system types that are used on Linux systems are described below.
File system types
Ext4 is the fourth generation of the ext file system, released in 2008 and pretty much the default since 2010. It supports file systems as big as 16 terabytes. It also supports unlimited subdirectories where ext3 only supports 32,000. Yet it’s backward compatible with both ext3 and ext2, thus allowing them to be mounted with the same driver. Ext4 is also very stable, widely supported and compatible with solid state drives.
JFS is a journaling file system (thus the name) developed by IBM for AIX Unix. It allows for quick file system recovery after a crash by logging file metadata.
XFS is currently the default file system in Red Hat Enterprise Linux. Due to the way it lays out files as extents, it is less vulnerable to fragmentation than ext4.
ZFS is a file system that began life as part of Sun Microsystems’ Solaris OS. It provides robust data repair features and high storage capacity and is good for large-scale data storage.
ReiserFS is an alternative to the ext3 file system, but with better performance and some advanced features.
Btrfs (which stands for “B-tree file system”) is a file system that prioritizes data integrity, fault tolerance and easy administration. It supports advanced features like snapshots, built-in RAID, and copy-on-write.
Vfat is a file system type that contains the bootloader. It’s commonly referred to as the “boot partition”.
Tmpfs is a file system type which keeps all of its files in virtual memory.
You are unlikely to see more than a handful of these on most Linux systems.
Commands that display file system types
There are many ways to determine file system types on Linux. This section covers six different commands and one system file. The details provided by the commands often depend on options used and some require sudo privileges.
Using the lsblk command
The lsblk command provides details on specified block devices. With no options, you will see something like this:
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 14.9G 0 disk ├─sda1 8:1 0 600M 0 part /boot/efi ├─sda2 8:2 0 1G 0 part /boot └─sda3 8:3 0 13.3G 0 part /home / zram0 252:0 0 3.7G 0 disk [SWAP]
As you can see, it provides partition names (e.g., sda1), major and minor device numbers (the major number is the larger, more generic category), RM (removable or not), the size, type (disk or partition) and the mount point. An RM of 0 indicates the disk or partition is not removable.
In the command below, the options used specifically request that the file system type (FSTYPE) be included.
$ lsblk -o PATH,FSTYPE,MOUNTPOINT /dev/sda PATH FSTYPE MOUNTPOINT /dev/sda /dev/sda1 vfat /boot/efi /dev/sda2 ext4 /boot /dev/sda3 btrfs /home
The lsblk command with the -f option includes file system version information, the UUIDs and both available and used space.
$ lsblk -f NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS sda ├─sda1 vfat FAT32 6E4A-5BD5 581.4M 3% /boot/efi ├─sda2 ext4 1.0 444b22ab-9206-4f97-b1c3-b8832d294401 609.4M 30% /boot └─sda3 btrfs fedora_localhost-live d961ea75-eaa0-425a-b378-fe2bc7e3a9ce 8.5G 32% /home / zram0 [SWAP]
Using the blkid command
The blkid command requires the use of sudo privilege and supplies information like that shown below including the partition names, UUIDs, block size, file system type and PARTUUID (raw physical storage partition UUID).
$ sudo blkid [sudo] password for fedora: /dev/sda2: UUID="444b22ab-9206-4f97-b1c3-b8832d294401" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="344a7c0d-2aa0-44c1-8d49-2ea763659119" /dev/sda3: LABEL="fedora_localhost-live" UUID="d961ea75-eaa0-425a-b378-fe2bc7e3a9ce" UUID_SUB="61a2f8bf-8cec-4bbc-b426-cb1aa226d027" BLOCK_SIZE="4096" TYPE="btrfs" PARTUUID="98d3521c-18b9-45e0-a5b2-b817323f8e89" /dev/sda1: UUID="6E4A-5BD5" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="371effc8-5c7b-4838-9d9e-ee22d9d7ab55" /dev/zram0: LABEL="zram0" UUID="1f5a53e0-6657-447b-958d-86e84482d829" TYPE="swap"
Using the df command
The df command with the -T option will display details for file systems in the format shown below.
$ df -T Filesystem Type 1K-blocks Used Available Use% Mounted on devtmpfs devtmpfs 4096 0 4096 0% /dev tmpfs tmpfs 1934144 0 1934144 0% /dev/shm tmpfs tmpfs 773660 1596 772064 1% /run /dev/sda3 btrfs 13974528 4447900 8879700 34% / tmpfs tmpfs 1934148 16 1934132 1% /tmp /dev/sda3 btrfs 13974528 4447900 8879700 34% /home /dev/sda2 ext4 996780 303944 624024 33% /boot /dev/sda1 vfat 613160 17780 595380 3% /boot/efi tmpfs tmpfs 386828 124 386704 1% /run/user/1000
Adding the -H option alters the numbers use to make them more human-friendly.
$ df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 4.0M 0 4.0M 0% /dev tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs tmpfs 756M 1.6M 754M 1% /run /dev/sda3 btrfs 14G 4.3G 8.5G 34% / tmpfs tmpfs 1.9G 16K 1.9G 1% /tmp /dev/sda3 btrfs 14G 4.3G 8.5G 34% /home /dev/sda2 ext4 974M 297M 610M 33% /boot /dev/sda1 vfat 599M 18M 582M 3% /boot/efi tmpfs tmpfs 378M 124K 378M 1% /run/user/1000
Using the mount command
The mount command displays file system types along with a lot of additional information. The command below ensures that only details about disk devices are included in the output.
$ mount | grep ^/dev /dev/sda3 on / type btrfs (rw,relatime,seclabel,compress=zstd:1,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/root) /dev/sda3 on /home type btrfs (rw,relatime,seclabel,compress=zstd:1,ssd,discard=async,space_cache=v2,subvolid=256,subvol=/home) /dev/sda2 on /boot type ext4 (rw,relatime,seclabel) /dev/sda1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro)
Using fsck
The fsck command with the -N option will display file system types without performing a file system check as the command normally would.
$ fsck -N /dev/sda1 fsck from util-linux 2.38.1 [/usr/sbin/fsck.vfat (1) -- /boot/efi] fsck.vfat /dev/sda1 $ fsck -N /dev/sda3 fsck from util-linux 2.38.1 [/usr/sbin/fsck.btrfs (1) -- /] fsck.btrfs /dev/sda3
Using the file command
The file command as shown below will display the file system type along with the device label, sector size and other details.
$ sudo file -sL /dev/sda3 /dev/sda3: BTRFS Filesystem label "fedora_localhost-live", sectorsize 4096, nodesize 16384, leafsize 16384, UUID=d961ea75-eaa0-425a-b378-fe2bc7e3a9ce, 4340412416/14309916672 bytes used, 1 devices
Examining /etc/fstab
You can also retrieve information on file system types by looking at the /etc/fstab file.
$ cat /etc/fstab # # /etc/fstab # Created by anaconda on Sat Jan 28 20:15:39 2023 # # Accessible filesystems, by reference, are maintained under '/dev/disk/'. # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. # # After editing this file, run 'systemctl daemon-reload' to update systemd # units generated from this file. # UUID=d961ea75-eaa0-425a-b378-fe2bc7e3a9ce / btrfs subvol=root,compress=zstd:1 0 0 UUID=444b22ab-9206-4f97-b1c3-b8832d294401 /boot ext4 defaults 1 2 UUID=6E4A-5BD5 /boot/efi vfat umask=0077,shortname=winnt 0 2 UUID=d961ea75-eaa0-425a-b378-fe2bc7e3a9ce /home btrfs subvol=home,compress=zstd:1 0
An easier option would be to use a command like what is shown below and limit the output to just the mount point and file system types.
$ cat /etc/fstab | grep -v ^# | awk ‘{print $2,$3}’ / btrfs /boot ext4 /boot/efi vfat /home btrfs
Wrap-up
There are so many Linux commands ready to provide details on file system types that choosing a favorite or two and setting them up as aliases might be a good idea!
Copyright © 2023 IDG Communications, Inc.