KNZLABS :: RHCSA Foundations

Module 3: Configure Local Storage

RHCSA domain covered: Configure Local Storage (4).

Lab in this kit: Lab 05 (Partitions, LVM, swap, XFS).

Storage on Linux is a stack of layers, and the exam expects you to be fluent at every level — and, crucially, to make your work persist across a reboot. The mental model below is the whole domain in one picture: a raw disk becomes a partition, the partition becomes an LVM building block, those blocks combine into a resizable logical volume, you put a filesystem on it, mount it, and record that mount in /etc/fstab so it comes back after a reboot.

The storage stack, bottom up


disk (/dev/sdb)
  └─ partition (/dev/sdb1)
       └─ physical volume (pvcreate)
            └─ volume group (vgcreate vg_lab)
                 └─ logical volume (lvcreate lv_app)
                      └─ filesystem (mkfs.xfs)
                           └─ mount point (/srv/app)
                                └─ /etc/fstab entry (persistence)

Each layer wraps the one below it. The payoff of LVM (the middle three layers) is flexibility: you can grow a logical volume by adding disks to its volume group, without repartitioning or moving data. That flexibility is exactly what the exam tests.

Partitioning

What it is: carving a raw disk into named regions the kernel can address separately.

Why it matters: it's the first layer of the stack, and the exam expects you to create partitions of specific sizes and have the kernel recognize them without a reboot.


# Modern, scriptable: parted
parted /dev/sdb mklabel gpt                     # write a GPT partition table
parted /dev/sdb mkpart primary 1MiB 1025MiB     # a 1 GiB partition
parted /dev/sdb mkpart primary 1025MiB 100%     # use the rest

# Classic, interactive: fdisk (GPT-aware on RHEL 9+)
fdisk /dev/sdb        # n (new), p (primary), +1G (size), w (write)

# Make the kernel see the change, then confirm
partprobe /dev/sdb
lsblk

parted is non-interactive, which makes it the better choice under time pressure — one command per partition, no menu navigation. The step people forget is partprobe: after you change the partition table, the *kernel* may still hold the old layout in memory, so your shiny new /dev/sdb1 doesn't exist yet to commands like mkfs. partprobe (or udevadm settle) forces the kernel to re-read the table. Always lsblk afterward to confirm the partition actually appeared.

The LVM workflow

What it is: Logical Volume Manager inserts an abstraction layer between physical disks and filesystems. Physical volumes (PVs) are disks/partitions initialized for LVM; a volume group (VG) pools their space; logical volumes (LVs) are carved from the pool and act like resizable partitions.

Why it matters: this is the most-tested storage skill on the RHCSA. "Create a 2 GiB logical volume named X in volume group Y and mount it at Z, persistently" is a canonical task — and "now grow it" is the follow-up.


pvcreate /dev/sdc                       # initialize a disk/partition as a PV
vgcreate vg_lab /dev/sdc                # create a VG from one PV
vgextend vg_lab /dev/sdd                # later: add more space to the VG

lvcreate -L 1G -n lv_app vg_lab         # 1 GiB LV by absolute size
lvcreate -l 100%FREE -n lv_data vg_lab  # an LV using all remaining space

mkfs.xfs /dev/vg_lab/lv_app             # put a filesystem on it
mkdir -p /mnt/app && mount /dev/vg_lab/lv_app /mnt/app

# Grow the LV by 1 GiB AND its filesystem, in one command:
lvextend -L +1G -r /dev/vg_lab/lv_app

Two flags carry most of the weight here. The size flag comes in two forms: -L 1G is an *absolute* size (uppercase L, a capacity), while -l 100%FREE is an *extent-based* spec (lowercase l, "all the space that's left"). The extend operation is where people lose points: lvextend -L +1G *adds* a gigabyte (note the +), whereas lvextend -L 1G *sets the size to* 1 GiB — which would shrink most volumes and destroy data. And the -r flag is the time-saver: it resizes the filesystem to match the new LV size in the same step, calling xfs_growfs or resize2fs for you so you never have to remember which.

Swap

What it is: disk space the kernel uses as overflow when RAM fills. You can make a partition or logical volume into swap.

Why it matters: "add swap" is a common task, and like every storage task it has to survive a reboot.


mkswap /dev/sdb1                         # format the device as swap
swapon /dev/sdb1                         # activate it now
swapon --show                            # confirm it's active

# Persist it in fstab (note: "none" mount point, "swap" type)
echo "UUID=$(blkid -s UUID -o value /dev/sdb1) none swap defaults 0 0" >> /etc/fstab

Swap is the one fstab entry that doesn't have a real mount point — the mount-point field is none and the type is swap. swapon --show (or free -h) confirms the runtime state; the fstab line is what brings it back after reboot. As always, the runtime command (swapon) and the persistence (fstab) are two separate steps and the exam scores the persistent one.

fstab essentials

What it is: the table that defines persistent mounts. Six fields: source, mount point, filesystem type, options, dump, and fsck pass order.

Why it matters: it's the persistence layer for *every* storage task, and a single bad line can make the machine refuse to boot.


UUID=abc-123  /mnt/app  xfs    defaults,noatime          0 0
UUID=def-456  /mnt/log  ext4   defaults,nosuid,nodev     0 2
UUID=ghi-789  none      swap   defaults                  0 0

Always identify the source by UUID= rather than a /dev/sdX name. Device names are assigned in discovery order and can shuffle when you add a disk — an fstab full of device names is a reboot away from mounting the wrong volumes. The last two numeric fields are usually 0 0 (the dump field is obsolete; the fsck pass is 1 for root, 2 for other ext-family filesystems, 0 to skip — XFS ignores it entirely). The non-negotiable habit: after editing fstab, run mount -a. It re-reads the file and mounts everything; if you made a mistake, it fails *now* at a prompt instead of at next boot in emergency mode.

Common pitfalls

  • Forgetting partprobe (or udevadm settle) after parted → the kernel doesn't see the new partition and mkfs can't find it.
  • lvextend -L 5G is *absolute* (set to 5 GiB); lvextend -L +5G is *relative* (add 5 GiB). Mixing them up shrinks or wastes the volume.
  • Editing fstab and never running mount -a → a bad entry drops the system into emergency mode on next boot. Always mount -a before you reboot.
  • Resizing XFS uses xfs_growfs; ext4 uses resize2fs — they are not interchangeable. Let lvextend -r pick the right one.
  • Using /dev/sdX names in fstab instead of UUIDs → mounts break when disk ordering changes between boots.

Exam tips

  • Memorize two inspection commands cold: blkid (UUIDs and types) and lsblk -o NAME,UUID,FSTYPE,MOUNTPOINT,SIZE (the whole stack at a glance). You'll run them constantly.
  • Build fstab UUID lines without typos: blkid -s UUID -o value /dev/... prints just the bare UUID, ready to paste.
  • Practice the entire stack — partition → PV → VG → LV → mkfs → mount → fstab → mount -a → verify — until you can do it under five minutes without looking anything up. It's the single highest-value drill in storage.
Next: Module 4 — File systems including Stratis.