VFAT, ext4, and XFS
File Systems

Create, mount, unmount, and use VFAT, ext4, and XFS file systems

CIS126RH | RHEL System Administration 1
Mesa Community College

Linux supports many filesystem types. RHEL 9 administrators routinely work with three: XFS (the default for new RHEL installations, high performance, scalable), ext4 (the mature Linux workhorse with broad tool support), and VFAT (the Windows-compatible filesystem used on USB drives and the EFI system partition). This module covers creating, mounting, unmounting, and verifying all three filesystem types. These skills are tested on the RHCSA exam.

Learning Objectives

  1. Compare XFS, ext4, and VFAT — Describe the key characteristics, strengths, and appropriate use cases for each filesystem type
  2. Create filesystems with mkfs — Use mkfs.xfs, mkfs.ext4, and mkfs.vfat to format partitions and logical volumes
  3. Mount and unmount filesystems — Use mount and umount to attach and detach filesystems, and configure persistent mounts in /etc/fstab
  4. Inspect and verify filesystems — Use df, du, blkid, and lsblk -f to report filesystem type, usage, and mount status

Filesystem Comparison: XFS, ext4, VFAT

Feature XFS ext4 VFAT
RHEL 9 defaultYes — root and data volumesOptionalEFI partition only
JournalingYes — metadata journalYes — data + metadataNo
Max file size8 EiB16 TiB4 GiB (FAT32 limit)
Max volume size8 EiB1 EiB2 TiB (FAT32)
Online growYes — while mountedYes — while mountedNo
ShrinkNoYes — unmounted onlyNo
Linux permissionsFull POSIXFull POSIXNone — all files appear owned by mount user
Cross-platformLinux onlyLinux primaryWindows, macOS, Linux — universal
Typical useServer filesystems, databasesGeneral Linux filesystemsUSB drives, EFI partition, shared media

Creating an XFS Filesystem

XFS is the default RHEL 9 filesystem. mkfs.xfs formats a partition or logical volume with XFS.

# Format a partition with XFS (default options)
$ sudo mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1           isize=512  agcount=4, agsize=655360 blks
         =                    sectsz=512 attr=2, projid32bit=1
         =                    crc=1      finobt=1, sparse=1, rmapbt=0
         =                    reflink=1  bigtime=1 inobtcount=1
data     =                    bsize=4096 blocks=2621440, imaxpct=25
         =                    sunit=0    swidth=0 blks
naming   =version 2           bsize=4096 ascii-ci=0, ftype=1
log      =internal log        bsize=4096 blocks=2560, version=2
realtime =none                extsz=4096 blocks=0, rtextents=0

# Format with a label at creation time
$ sudo mkfs.xfs -L datafs /dev/sdb1

# Force format even if a filesystem already exists
$ sudo mkfs.xfs -f /dev/sdb1

# Verify XFS filesystem was created
$ sudo blkid /dev/sdb1
/dev/sdb1: LABEL="datafs" UUID="abc123-..." TYPE="xfs"
-f flag overwrites existing filesystem

mkfs.xfs refuses to format a device that already contains a filesystem without the -f (force) flag. This safety feature prevents accidental reformatting.

Creating an ext4 Filesystem

ext4 is the mature Linux filesystem with full journaling and broad tool support. mkfs.ext4 formats a partition with ext4.

# Format a partition with ext4 (default options)
$ sudo mkfs.ext4 /dev/sdb1
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 2621440 4k blocks and 655360 inodes
Filesystem UUID: def456-gh78-...
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, ...

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

# Format with a label
$ sudo mkfs.ext4 -L webroot /dev/sdb1

# Verify
$ sudo blkid /dev/sdb1
/dev/sdb1: LABEL="webroot" UUID="def456-gh78-..." TYPE="ext4"

# Show ext4 filesystem details
$ sudo tune2fs -l /dev/sdb1 | grep -E "Filesystem (UUID|label)|Block size"
Superblock backups

ext4 stores multiple copies of the superblock at regular intervals. This makes ext4 more resilient to corruption — if the primary superblock is damaged, e2fsck can recover from a backup copy.

Creating a VFAT Filesystem

VFAT (Virtual FAT) provides Windows-compatible storage. It is the filesystem for USB drives, the EFI system partition, and any storage that must be readable on non-Linux systems.

# Install the VFAT utilities if needed
$ sudo dnf install -y dosfstools

# Format a partition with VFAT (FAT32)
$ sudo mkfs.vfat /dev/sdb1
mkfs.fat 4.2 (2021-01-31)

# Format with FAT32 explicitly (-F 32) and a label (-n)
$ sudo mkfs.vfat -F 32 -n USBDRIVE /dev/sdb1

# Alternative command names (all equivalent)
$ sudo mkfs.fat /dev/sdb1
$ sudo mkdosfs /dev/sdb1

# Verify
$ sudo blkid /dev/sdb1
/dev/sdb1: SEC_TYPE="msdos" LABEL_FATBOOT="USBDRIVE" LABEL="USBDRIVE"
           UUID="1A2B-3C4D" TYPE="vfat"
VFAT labels are uppercase, max 11 characters

FAT filesystem labels are limited to 11 characters and are stored and displayed in uppercase. The UUID for VFAT is a 4-byte value (8 hex characters), much shorter than the 128-bit UUID used by XFS and ext4.

Mounting Filesystems: mount

The mount command attaches a filesystem to a directory in the filesystem hierarchy. The directory must exist before mounting.

# Mount by device path — filesystem type is auto-detected
$ sudo mount /dev/sdb1 /mnt/data

# Mount with explicit filesystem type
$ sudo mount -t xfs /dev/sdb1 /mnt/data
$ sudo mount -t ext4 /dev/sdb1 /mnt/data
$ sudo mount -t vfat /dev/sdb1 /mnt/usb

# Mount read-only
$ sudo mount -o ro /dev/sdb1 /mnt/data

# Mount by UUID
$ sudo mount UUID=abc123-de45-fg67-hi89-jk0123456789 /mnt/data

# Mount by label
$ sudo mount LABEL=datafs /mnt/data

# Mount all entries in /etc/fstab not yet mounted
$ sudo mount -a

# Show all currently mounted filesystems
$ mount
$ findmnt

VFAT-Specific Mount Options

VFAT has no concept of Linux file permissions. Special mount options control how ownership and permissions are presented to the OS.

# Mount VFAT with standard options for a USB drive
$ sudo mount -t vfat -o uid=1000,gid=1000,umask=022 \
    /dev/sdb1 /mnt/usb

# Allow all users to read and write (umask=000)
$ sudo mount -t vfat -o uid=0,gid=0,umask=000 \
    /dev/sdb1 /mnt/usb

# Typical /etc/fstab entry for a VFAT USB drive
UUID=1A2B-3C4D  /mnt/usb  vfat  defaults,uid=1000,gid=1000,umask=022  0 0

# Mount with UTF-8 character encoding (required for non-ASCII filenames)
$ sudo mount -t vfat -o utf8 /dev/sdb1 /mnt/usb
VFAT option Meaning
uid=NAll files appear owned by user with UID N
gid=NAll files appear owned by group with GID N
umask=022File permissions appear as 644 (dirs 755)
umask=000All files appear world-readable and writable
utf8Enable UTF-8 encoding for filenames

Unmounting Filesystems: umount

umount detaches a filesystem from the directory hierarchy. The filesystem must not be in use (no open files, no processes with the mount point as their working directory).

# Unmount by mount point (most common)
$ sudo umount /mnt/data

# Unmount by device
$ sudo umount /dev/sdb1

# Lazy unmount — detach immediately, cleanup when all processes close
$ sudo umount -l /mnt/data

# Diagnose why a filesystem cannot be unmounted
$ sudo fuser -vm /mnt/data
                     USER        PID ACCESS COMMAND
/mnt/data:           root       1234 ..c.. bash
                     student    5678 ..c.. vim

# lsof shows all files open within the mount point
$ sudo lsof /mnt/data

# Common error — "target is busy"
umount: /mnt/data: target is busy.
# Solution: find and close open files, or change directory out of /mnt/data
Cannot unmount when the filesystem is in use

If any process has files open in the mount point, or if any shell has the mount point as its current directory, umount fails with "target is busy". Use fuser -vm or lsof to find which process is blocking.

Checking Filesystem Usage: df and du

df shows filesystem-level disk usage. du shows directory-level disk usage.

# Show all mounted filesystems with human-readable sizes
$ df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   17G  4.5G   13G  27% /
/dev/sda1              1014M  221M  794M  22% /boot
/dev/sdb1               10G  104M  9.9G   2% /data

# Show filesystem type alongside usage
$ df -hT
Filesystem             Type  Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root  xfs    17G  4.5G   13G  27% /
/dev/sdb1              xfs    10G  104M  9.9G   2% /data
/dev/sdc1              ext4    5G  234M  4.8G   5% /archive
/dev/sdd1              vfat    4G  1.2G  2.8G  30% /mnt/usb

# Show disk usage of a directory tree
$ du -sh /data
3.2G    /data

# Show usage of top-level subdirectories
$ du -sh /data/*

# Show the 10 largest directories under /var
$ du -sh /var/* | sort -rh | head

Filesystem Inspection Tools

Several tools show filesystem type, UUID, and status without requiring the filesystem to be mounted.

# blkid — show UUID, label, and type for all devices
$ sudo blkid
/dev/sdb1: UUID="abc123-..." TYPE="xfs"
/dev/sdc1: LABEL="archive" UUID="def456-..." TYPE="ext4"
/dev/sdd1: LABEL="USBDRIVE" UUID="1A2B-3C4D" TYPE="vfat"

# lsblk -f — tree view with filesystem info
$ lsblk -f
NAME   FSTYPE FSVER LABEL    UUID                                 MOUNTPOINTS
sdb
└─sdb1 xfs          datafs   abc123-...                           /data
sdc
└─sdc1 ext4   1.0   archive  def456-...                           /archive
sdd
└─sdd1 vfat   FAT32 USBDRIVE 1A2B-3C4D                           /mnt/usb

# xfs_info — show XFS filesystem parameters
$ sudo xfs_info /data      # uses mount point

# tune2fs -l — show ext4 filesystem details
$ sudo tune2fs -l /dev/sdc1

# fsck — check and repair filesystem (run unmounted)
$ sudo fsck.ext4 /dev/sdc1
$ sudo xfs_repair /dev/sdb1

Persistent Mounts in /etc/fstab

All three filesystem types use the same fstab format. The filesystem type field and mount options differ by type.

# XFS — default options; fsck order 2 for non-root
UUID=abc123-de45-fg67-hi89  /data     xfs   defaults          0 2

# ext4 — same pattern
UUID=def456-gh78-ij90-kl12  /archive  ext4  defaults          0 2

# VFAT — with uid/gid for ownership; fsck order 0 (no fsck)
UUID=1A2B-3C4D               /mnt/usb  vfat  defaults,uid=1000,gid=1000,umask=022  0 0

# VFAT (optional removable) — nofail prevents boot failure if missing
UUID=1A2B-3C4D               /mnt/usb  vfat  defaults,nofail,uid=1000,umask=022    0 0

# Test all entries
$ sudo mount -a
$ findmnt --verify
$ df -hT   # confirm type column shows correct filesystem
VFAT fsck order must be 0

The sixth field (fsck order) must be 0 for VFAT. The fsck command does not understand VFAT — running it on a VFAT device causes errors. Only XFS and ext4 use 1 (root) or 2 (other).

XFS Filesystem Management Tools

XFS has its own set of filesystem management utilities that are distinct from the ext4 tools.

# Show XFS filesystem parameters (must be mounted)
$ xfs_info /data
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=655360 blks
data     =          bsize=4096 blocks=2621440, imaxpct=25
log      =internal  bsize=4096 blocks=2560, version=2

# Grow XFS filesystem (must be mounted; LV or partition must be larger)
$ sudo xfs_growfs /data

# Repair a corrupted XFS filesystem (must be unmounted)
$ sudo xfs_repair /dev/sdb1

# Set or change XFS filesystem label
$ sudo xfs_admin -L datafs /dev/sdb1   # set label
$ sudo xfs_admin -l /dev/sdb1          # read label

# Generate a new UUID for a cloned XFS filesystem
$ sudo xfs_admin -U generate /dev/sdb1

# Dump XFS filesystem metadata for diagnosis
$ sudo xfs_db -r /dev/sdb1

ext4 Filesystem Management Tools

ext4 uses the e2fsprogs toolset — a comprehensive set of utilities for creating, checking, and managing ext2/ext3/ext4 filesystems.

# Show complete ext4 filesystem parameters
$ sudo tune2fs -l /dev/sdc1
tune2fs 1.46.5 (30-Dec-2021)
Filesystem volume name:   archive
Last mounted on:          /archive
Filesystem UUID:          def456-gh78-...
Filesystem magic number:  0xEF53
Filesystem revision:      1 (dynamic)
...
Block size:               4096
Inode count:              655360
Block count:              2621440

# Change ext4 label
$ sudo tune2fs -L archive /dev/sdc1

# Check and repair ext4 (unmounted)
$ sudo e2fsck -f /dev/sdc1

# Grow ext4 (mounted or unmounted; partition/LV must be larger first)
$ sudo resize2fs /dev/sdc1

# Show ext4 block and inode usage (mounted)
$ sudo dumpe2fs -h /dev/sdc1 | grep "Block\|Inode"

Filesystem Quick Reference

Task XFS ext4 VFAT
Createmkfs.xfs /dev/Xmkfs.ext4 /dev/Xmkfs.vfat /dev/X
Create with labelmkfs.xfs -L NAMEmkfs.ext4 -L NAMEmkfs.vfat -n NAME
Mount type flag-t xfs-t ext4-t vfat
Show filesystem infoxfs_info /mnttune2fs -l /dev/Xdosfsck -n /dev/X
Set labelxfs_admin -L NAMEtune2fs -L NAMEmlabel -i /dev/X ::NAME
Check/repairxfs_repair /dev/Xe2fsck -f /dev/Xdosfsck /dev/X
Grow filesystemxfs_growfs /mntresize2fs /dev/XNot supported
fstab fsck order220

Common Mistakes

Mistake What goes wrong Correct approach
Using xfs_growfs with the device path instead of mount point xfs_growfs /dev/sdb1 fails: "not a mount point" xfs_growfs /data — XFS grow requires the mount point
Setting VFAT fsck order to 1 or 2 in fstab Boot runs fsck on a VFAT device — fsck does not support VFAT and reports errors Always use 0 in the sixth fstab field for VFAT
Forgetting -f when reformatting an existing filesystem mkfs.xfs refuses: "Use the -f option to force overwrite" sudo mkfs.xfs -f /dev/sdb1 to force the reformat
Unmounting fails with "target is busy" A shell or process has the mount point as its working directory Change to another directory (cd /) then retry umount
Running xfs_repair on a mounted filesystem xfs_repair warns about a dirty log and may corrupt the filesystem Always unmount before running xfs_repair
Copying a file larger than 4 GiB to a VFAT filesystem Copy fails: "File too large" — FAT32 file size limit is 4 GiB Use XFS or ext4 for large files; split large files before copying to VFAT

Knowledge Check

Answer these before moving to the next slide.

  1. Which filesystem type should you choose for a USB drive that must be readable on both Linux and Windows? Why can't you store a 5 GiB ISO image on it?
  2. Write the three commands to: format /dev/sdb1 as XFS with the label appdata, create the mount point /appdata, and mount it.
  3. Write the three commands to: format /dev/sdc1 as ext4, create the mount point /archive, and mount it with the -t flag.
  4. Write the fstab entries (using UUID) for the XFS filesystem from question 2 and the VFAT filesystem /dev/sdd1 (UUID: AABB-CCDD) mounted at /mnt/usb. What fsck order does VFAT use?
  5. umount /appdata fails with "target is busy". Write the command to find which process is blocking the unmount.
  6. What is the difference between xfs_growfs /appdata and resize2fs /dev/sdc1? What does each take as its argument?

Knowledge Check — Answers

  1. VFAT — it is the only filesystem type natively readable by both Linux and Windows without additional drivers. A 5 GiB ISO cannot be stored on it because FAT32 has a maximum individual file size of 4 GiB. Files exceeding this limit cannot be written to a FAT32 filesystem regardless of how much free space remains.
  2. sudo mkfs.xfs -L appdata /dev/sdb1
    sudo mkdir -p /appdata
    sudo mount /dev/sdb1 /appdata
  3. sudo mkfs.ext4 /dev/sdc1
    sudo mkdir -p /archive
    sudo mount -t ext4 /dev/sdc1 /archive
  4. XFS entry: UUID=abc123-... /appdata xfs defaults 0 2
    VFAT entry: UUID=AABB-CCDD /mnt/usb vfat defaults,uid=1000,gid=1000,umask=022 0 0
    VFAT must use fsck order 0 — the standard fsck command does not support FAT filesystems.
  5. sudo fuser -vm /appdata — shows all processes accessing the mount point, their PIDs, and what type of access they have. Also accept: sudo lsof /appdata.
  6. xfs_growfs takes the mount point as its argument and the filesystem must be mounted. resize2fs takes the device path and works mounted or unmounted. Both grow the filesystem after the underlying block device (partition or LV) has been enlarged.

Key Takeaways

  1. XFS is the RHEL 9 default — use it for server filesystems. ext4 for general Linux. VFAT for cross-platform removable media. VFAT has no POSIX permissions and a 4 GiB file size limit. XFS and ext4 support online growing; VFAT does not.
  2. Creation commands: mkfs.xfs, mkfs.ext4, mkfs.vfat. Use -L NAME for XFS and ext4 labels; -n NAME for VFAT. Use -f to force XFS formatting over an existing filesystem. Verify with sudo blkid after formatting.
  3. Mount and unmount with mount and umount. The mount point directory must exist before mounting. "Target is busy" — use fuser -vm to find blocking processes. Use -t fstype when type auto-detection is insufficient.
  4. In fstab: VFAT always uses fsck order 0; XFS and ext4 use 2. Use df -hT to confirm the filesystem type in mount output. Add nofail for removable VFAT devices. Test every fstab entry with sudo mount -a before rebooting.

Graded Lab

  • Using three separate partitions on a second disk, create one XFS filesystem, one ext4 filesystem, and one VFAT filesystem. Set a label on each using the appropriate flag at format time.
  • Create mount points /labxfs, /labext4, and /labvfat. Mount each filesystem using the correct -t flag. Confirm with df -hT that all three show the correct filesystem type.
  • Run sudo blkid and record the UUID of each new filesystem. Add all three to /etc/fstab using UUID, with correct options and fsck order for each type. Test with sudo mount -a.
  • Create a test file in each mount point. Unmount /labxfs by mount point and /labext4 by device path. Observe "target is busy" by running cd /labvfat and then attempting to unmount it. Use fuser -vm /labvfat to diagnose, then fix it.
  • Run findmnt --verify to validate all fstab entries. Run xfs_info /labxfs and tune2fs -l /dev/PARTDEV to inspect filesystem metadata for each type.
  • Reboot and confirm all three filesystems are mounted at startup with df -hT and that the test files created in step 4 are still present.
RHCSA Objective

"Create, mount, unmount, and use VFAT, ext4, and XFS file systems." Know all three mkfs commands and their label flags. Know VFAT's fsck order 0 rule. Test with mount -a before rebooting.