// learn Β· linux Β· rhcsa Β· 9 min

File systems & mounts.

A partition is just bytes until you format it with a filesystem and mount it somewhere. Watch a block device become an XFS filesystem, get mounted, and survive a reboot via /etc/fstab β€” then learn the options that govern its behavior.

Linux filesystems and mounts animated tutorial. mkfs.xfs and mkfs.ext4, the mount command, mount options, /etc/fstab format and UUIDs, fsck and tune2fs, xfs_growfs and resize2fs. RHCSA EX200 ready.
// filesystems & mounts

From a bare partition to a mounted, persistent filesystem β€” six layers, all with their own commands.

// before you start
you should know
  • Β·The partitions lesson (lsblk, blkid)
  • Β·Comfortable as root
  • Β·Know what a journaling filesystem is, vaguely
by the end you'll

Format a partition with mkfs, mount it, persist it in /etc/fstab using UUID, pick the right mount options, and grow / check it.

pace: 9 minutes

filesystem stack β€” step 1 / 6 Β· pick FS
1. block device
/dev/sdb1
2. filesystem
(none)
3. mount point
(unmounted)
4. /etc/fstab
(no entry)

Pick a filesystem β€” XFS or ext4

Two RHCSA defaults: XFS (RHEL's default since 7) β€” fast, scales to huge volumes, grows online but CANNOT shrink. ext4 β€” slightly older, slower at scale, supports BOTH grow and shrink (offline shrink). Pick XFS unless you specifically need to shrink. Both journal, both are stable.

$lsblk -f /dev/sdb1
$blkid /dev/sdb1
// key insight

The chain: block device β†’ filesystem β†’ mount β†’ fstab. Skip the last step and your work vanishes at reboot. ALWAYS run `mount -a` after editing fstab β€” if you don't, the next reboot might drop into emergency mode and the only way out is rescue media.

// exam-ready Β· mkfs, mount, fstab, repair
$mkfs.xfs / mkfs.ext4 DEV
$mkfs.xfs -L LABEL DEV
$mount DEV MOUNTPOINT
$umount MOUNTPOINT
$mount -a
$mount -o remount,ro DIR
$findmnt / findmnt --verify
$lsof DIR / fuser -mv DIR
$blkid DEV
$/etc/fstab
$xfs_growfs MP
$resize2fs DEV
$xfs_repair DEV (unmounted)
$fsck.ext4 -y DEV
$tune2fs -l DEV
$df -hT / du -sh DIR
// check yourself
4 quick questions
Q1

You added a new line to /etc/fstab and want to verify it works WITHOUT rebooting.

Q2

You need to SHRINK a filesystem. Which filesystem can you use?

Q3

`umount /data` returns 'target is busy'. How do you find the culprit?

Q4

Why reference partitions by UUID in /etc/fstab?

These aren't graded β€” they're just for active recall, which is what actually makes the lesson stick.

πŸ’Ύ
// next layer up

LVM stacking

Put LVM between the partition and the filesystem and growing space online becomes one command. See the whole stack: disks β†’ PVs β†’ VG β†’ LVs β†’ FS.

open β†’

Read this lesson as text6 chapters Β· quiz answers

  1. 01Pick a filesystem β€” XFS or ext4

    Two RHCSA defaults: XFS (RHEL's default since 7) β€” fast, scales to huge volumes, grows online but CANNOT shrink. ext4 β€” slightly older, slower at scale, supports BOTH grow and shrink (offline shrink). Pick XFS unless you specifically need to shrink. Both journal, both are stable.

    • $ lsblk -f /dev/sdb1 β€” what's there now (probably nothing)
    • $ blkid /dev/sdb1 β€” blank? blkid says nothing
  2. 02mkfs β€” format the partition

    mkfs.xfs /dev/sdb1 writes an XFS filesystem onto the block device β€” superblock, inodes, journal, the works. mkfs.ext4 /dev/sdb1 for ext4. -L mylabel sets a human label. The command takes seconds for normal sizes. DESTRUCTIVE: anything previously on the device is gone.

    • $ mkfs.xfs /dev/sdb1 β€” format as XFS
    • $ mkfs.xfs -L data /dev/sdb1 β€” with a label
    • $ mkfs.ext4 /dev/sdb1 β€” ext4 instead
    • $ blkid /dev/sdb1 β€” now has TYPE + UUID
  3. 03mount β€” attach it to the tree

    A filesystem only becomes usable when mounted at a directory. mkdir -p /data && mount /dev/sdb1 /data makes anything written into /data go onto the new filesystem. The mount lives only until reboot or umount. mount with no args lists everything currently mounted; findmnt is the pretty version.

    • $ mkdir -p /data β€” create mount point
    • $ mount /dev/sdb1 /data β€” mount it
    • $ mount | grep /data β€” verify
    • $ umount /data β€” detach
    • $ lsof /data / fuser -mv /data β€” umount busy? find who's using it
  4. 04Persist with /etc/fstab

    /etc/fstab is the boot-time mount list. Format: <device> <mountpoint> <fstype> <options> <dump> <pass>. Always use UUID= (from blkid) β€” device names can shift when disks are added or reordered. After editing, test with mount -a (mounts everything not already mounted) β€” if it fails, fix BEFORE rebooting or the system may drop to emergency mode. findmnt --verify checks the file for syntax.

    • $ blkid /dev/sdb1 β€” get UUID
    • $ echo 'UUID=… /data xfs defaults 0 0' >> /etc/fstab β€” persist
    • $ mount -a β€” TEST without rebooting
    • $ findmnt --verify β€” syntax check fstab
  5. 05Mount options that matter

    The options column of fstab tunes behavior. defaults = rw,suid,dev,exec,auto,nouser,async (covers most cases). Useful overrides: ro (read-only), noexec (no executables β€” /tmp hardening), nosuid (ignore SUID β€” /home hardening), noatime (don't update access time β€” perf win), nofail (don't block boot if the device is missing β€” great for removable disks). Combine with commas: defaults,noexec,nosuid.

    • $ mount -o remount,ro /data β€” remount read-only without unmounting
    • $ mount -o noexec,nosuid /dev/sdb1 /tmp β€” harden /tmp
    • $ mount -o noatime … β€” skip atime writes (perf)
    • $ mount -o nofail … β€” don't block boot if absent
  6. 06Grow, check, repair

    XFS grows online with xfs_growfs /data once the underlying LV/partition is bigger. ext4 uses resize2fs /dev/sdb1 (online for grow, offline for shrink). fsck checks/repairs an UNMOUNTED filesystem (xfs_repair for XFS). RHEL won't fsck a mounted FS; for the root FS, set the 6th fstab column to 1 (root) or 2 (other) and the boot scripts will run it for you.

    • $ xfs_growfs /data β€” grow XFS online
    • $ resize2fs /dev/sdb1 β€” grow/shrink ext4
    • $ xfs_repair /dev/sdb1 β€” repair (UNMOUNTED)
    • $ fsck.ext4 -y /dev/sdb1 β€” ext4 repair
    • $ tune2fs -l /dev/sdb1 β€” ext4 superblock info

Quiz β€” answers

You added a new line to /etc/fstab and want to verify it works WITHOUT rebooting.
β†’Run mount -a β€” it mounts everything in fstab that isn't already mounted. If your new entry has a syntax error or bad device, you find out NOW instead of in emergency mode after a reboot.ALWAYS mount -a after editing fstab. A bad entry can drop the next boot into emergency mode. findmnt --verify is a syntax-only check that complements it.
You need to SHRINK a filesystem. Which filesystem can you use?
β†’ext4 β€” supports shrinking (offline, with resize2fs).XFS grows but does NOT shrink β€” at all. ext4 supports shrink, but the FS must be unmounted first. If you need shrink capability, choose ext4 up front (or migrate by recreating).
umount /data returns 'target is busy'. How do you find the culprit?
β†’lsof /data or fuser -mv /data β€” lists every open file descriptor and process inside the mount. Kill or change directory out, then umount cleanly.Both lsof and fuser show what's keeping the mount busy β€” often someone's shell sitting in that directory, or a service writing logs there. umount -f can leave open files in odd states; identify and stop the user(s) first.
Why reference partitions by UUID in /etc/fstab?
β†’Because /dev/sdXn names depend on enumeration order β€” add or remove a disk and the names shift. UUIDs are tied to the filesystem and stay stable.The kernel assigns sd* names in the order it finds disks. Adding an extra disk can rename your boot disk to sdb. UUIDs (from blkid) stay with the filesystem itself, so fstab keeps working.
// more in linux

keep going β€” these pair well with what you just learned.

see all linux β†’

See also

back to RHCSA trackall lessons