Understanding Linux Filesystems and Their Utilities
This post provides a beginner-friendly Linux filesystems overview, covering the ext4 and XFS formats along with key utilities like df, du, fsck, and xfs_repair. It explains when and why each filesystem type is used and demonstrates practical terminal commands for managing storage. Ideal for Linux+
When you start working with Linux storage, one of the first things you need to understand is how filesystems work. A filesystem is the structure that controls how data is stored and retrieved on a disk. Without it, your operating system would have no way to organize files or know where anything lives. For the Linux+ exam and real-world administration, knowing the major filesystem types and the tools used to manage them is essential.
Common Linux Filesystem Types
Linux supports a wide variety of filesystem formats. For day-to-day administration and the Linux+ exam, you will encounter a handful of these regularly.
ext4
The Fourth Extended Filesystem (ext4) is the default filesystem on many Linux distributions, including Ubuntu and Debian. It supports large files and volumes, journaling (which helps recover from crashes), and is extremely well-tested. Most Linux administrators are familiar with ext4 utilities since it has been the standard for over a decade.
XFS
The XFS format is the default on Red Hat Enterprise Linux (RHEL) and CentOS systems. It is a high-performance, 64-bit journaling filesystem that handles large files and high-throughput workloads exceptionally well. One important thing to know: XFS filesystems can be grown but cannot be shrunk. Keep that in mind when planning storage.
Btrfs
Btrfs (B-Tree Filesystem) is a newer filesystem with advanced features like snapshots, built-in RAID support, and subvolumes. It is gaining adoption but is less common in production than ext4 or xfs for now.
vfat and exFAT
These are used primarily for removable media and cross-platform compatibility. You will not use them for your root partition, but you will see them on USB drives and SD cards.
Creating a Filesystem
Once a partition or logical volume exists, you format it with a filesystem using the mkfs command family. Here are examples for both major types:
# Format a partition with ext4
sudo mkfs.ext4 /dev/sdb1
# Format a partition with XFS
sudo mkfs.xfs /dev/sdb2Always double-check your device names before running mkfs. Formatting the wrong device will destroy your data.
Essential Filesystem Utilities
Beyond creating filesystems, you need tools to monitor, check, and troubleshoot them. These come up constantly in real-world administration and on the Linux+ exam.
df: Disk Free Space
The df command reports how much disk space is used and available on mounted filesystems. The -h flag gives you human-readable output:
df -hExample output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 18G 30G 38% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
/dev/sdb1 100G 45G 55G 46% /datadu: Disk Usage
While df shows filesystem-level usage, du shows how much space individual directories and files are consuming. This is useful for finding what is eating up your disk space:
# Show the size of a specific directory
du -sh /var/log
# Show sizes of all subdirectories
du -h --max-depth=1 /homefsck: Filesystem Check
The fsck command (Filesystem Check) scans and repairs filesystem errors. It is the Linux equivalent of checking a disk for errors. A critical rule: always run fsck on an unmounted filesystem. Running it on a mounted filesystem can cause further corruption.
# Check an unmounted ext4 partition
sudo fsck /dev/sdb1
# Force a check even if the filesystem appears clean
sudo fsck -f /dev/sdb1For XFS filesystems, the equivalent tool is xfs_repair:
sudo xfs_repair /dev/sdb2Linux fsck also runs automatically at boot if a filesystem was not cleanly unmounted, which is why you sometimes see a disk check happening during startup.
Quick Reference Summary
- ext4: default on Ubuntu/Debian, stable, journaled, fully shrinkable
- xfs: default on RHEL/CentOS, high performance, can grow but not shrink
- mkfs.ext4 / mkfs.xfs: create filesystems on a partition
- df -h:
- check available disk space across all mounted filesystems
- du -sh: check how much space a directory is using
- fsck: check and repair ext-based filesystems (unmounted only)
- xfs_repair: repair XFS filesystems
What's Next
Now that you understand filesystem types and the utilities used to manage them, the next step is learning how Linux mounts filesystems and manages them at boot using /etc/fstab. Understanding mount points and persistent mounts is the natural continuation of this topic and is also covered on the Linux+ exam. We will walk through that in the next post.
If you want to go deeper on storage management and filesystem concepts, the CompTIA Linux+ Study Guide by Richard Blum covers this domain thoroughly alongside practice questions mapped to the exam objectives.
Tools and resources for this topic
- CompTIA Linux+ Study Guide — Comprehensive Linux+ exam preparation covering system administration, security, and scripting.