Domain 4Running SystemsCORE

Managing Mounting Storage

Comprehensive guide on MBR and GPT partition management, formatting file systems (XFS/Ext4), configuring persistent mounts in /etc/fstab, and managing swap storage.

Domain: Configure local storage•Updated: 2026-08-30
#Storage#Partitioning#Fstab#GPT#MBR#Swap#Ext4#XFS#RHCSA#RHEL

Managing Mounting Storage

Theory Questions

1. Compare advantages of GUID partition tables (GPT) versus MBR partition tables.

  • Command(s):
fdisk -l /dev/sdb
gdisk -l /dev/sdb
  • Why: GPT (GUID Partition Table) is the modern partitioning standard that replaces legacy MBR (Master Boot Record). Key advantages include:

  • Partition Limit: GPT supports up to 128 primary partitions natively in Linux, whereas MBR is restricted to 4 primary partitions (or 3 primary + 1 extended partition).

  • Disk Capacity: GPT supports disk sizes up to 9.4 ZB (64-bit LBA), whereas MBR is limited to 2 TiB (32-bit LBA).

  • Redundancy & Integrity: GPT stores primary partition headers at the start of the disk and backup headers at the end, alongside CRC32 checksums for corruption detection. MBR stores its partition table in a single sector (LBA 0) with no built-in backup.

  • Gotchas: On RHCSA exams, creating partitions on disks larger than 2 TiB requires GPT. Creating MBR partitions on such disks will fail to utilize space beyond 2 TiB.

  • Verify:

parted /dev/sdb print | grep "Partition Table"

2. Evaluate statements about GPT partitions, identifying true and false claims.

  • Command(s):
gdisk -l /dev/sdb
  • Statements Evaluation:

  • True: GPT maintains a backup header at the end of the physical disk for redundancy.

  • True: GPT utilizes 64-bit Logical Block Addressing (LBA), enabling partition sizes greater than 2 TiB.

  • False: Legacy partition tools like fdisk cannot edit GPT disks on modern RHEL versions. (Correction: Utility fdisk in modern util-linux supports both MBR and GPT natively.)

  • Why: Modern RHEL distributions use upgraded utility suites (fdisk, gdisk, parted) capable of handling GPT partitioning schemas transparently.

  • Gotchas: Assuming fdisk only works on MBR; fdisk defaults to GPT if the disk has a GPT label or is initialized with g.

  • Verify:

fdisk -l /dev/sdb | grep "Disklabel type"

3. Identify the partition type commonly used for swap.

  • Command(s):
# MBR Type Code (fdisk):
82
# GPT Type Code (gdisk / fdisk):
0657  # (or 8200 in gdisk / Linux swap)
  • Why: Setting the correct partition type flag ensures udev rules, systemd automount generators, and installer utilities correctly identify the intended role of the partition.
  • Gotchas: Formatting a partition with mkswap without setting the partition type code in fdisk/gdisk works, but it fails strict RHCSA partition validation audits.
  • Verify:
fdisk -l /dev/sdb | grep -i "swap"

4. Identify the default disk device name in KVM virtual machines.

  • Command(s):
lsblk | grep -E "vd|sd|nvme"
  • Why: KVM/QEMU virtual machines in RHEL use VirtIO block storage drivers, which name storage devices starting with /dev/vdX (e.g., /dev/vda, /dev/vdb). SATA/SCSI devices appear as /dev/sdX, and NVMe drives appear as /dev/nvmeXnX.
  • Gotchas: Hardcoding /dev/sda in exam scripts or /etc/fstab when the KVM exam environment uses /dev/vda or /dev/vdb.
  • Verify:
ls -l /dev/vd*

5. Evaluate statements about GPT and MBR partition management tools.

  • Command(s):
fdisk -l /dev/sdb
gdisk -l /dev/sdb
parted /dev/sdb print
  • Statements Evaluation:

  • fdisk: Standard command-line utility for interactive partition creation; fully supports MBR and GPT in modern RHEL.

  • gdisk: Specifically designed for GPT disks; mirrors fdisk command syntax but converts MBR labels to GPT automatically.

  • parted: Non-interactive or scriptable CLI utility supporting both MBR (msdos) and GPT labels; allows immediate sector alignment.

  • Why: Knowing which tool fits the task speeds up storage management during performance-based testing.

  • Gotchas: parted writes changes to disk immediately without an explicit “write/save” step, whereas fdisk/gdisk require pressing w to commit changes.

  • Verify:

parted /dev/sdb print

6. Identify the default file system in RHEL 9.

  • Path / Command:
mkfs.xfs /dev/sdb1
  • Why: XFS is the default high-performance 64-bit journaling file system for RHEL 7, 8, 9, and 10, replacing Ext4 for standard system and data partitions.
  • Gotchas: XFS file systems can be grown online (xfs_growfs), but they cannot be shrunk. If a question requests a shrinkable file system, use Ext4.
  • Verify:
df -T /

7. Find current UUIDs for file systems on your server.

  • Command(s):
blkid
lsblk -f
  • Why: Universally Unique Identifiers (UUIDs) provide persistent block device identification. Device node names (like /dev/vdb1) can change across reboots if storage controllers enumerate in a different order.
  • Gotchas: Using /dev/vdb1 in /etc/fstab instead of UUID= can lead to boot failures if new disks are added to the system.
  • Verify:
lsblk -o NAME,FSTYPE,UUID,MOUNTPOINTS

8. Mount a file system by UUID in /etc/fstab.

  • Command(s):
# Step 1: Extract UUID
blkid /dev/sdb1

# Step 2: Append to /etc/fstab
echo "UUID=12345678-abcd-1234-abcd-123456789abc /mounts/data xfs defaults 0 0" >> /etc/fstab
  • Why: Configuring /etc/fstab with UUID= ensures persistent mounting at system startup regardless of block device identifier shifts.
  • Gotchas: Syntax errors or typos in UUID strings in /etc/fstab will cause the boot sequence to drop into emergency mode.
  • Verify:
findmnt --verify
mount -a

9. Verify /etc/fstab contents before rebooting.

  • Command(s):
findmnt --verify
mount -a
  • Why: findmnt --verify checks /etc/fstab for syntax errors, missing mount points, or duplicate entries. mount -a attempts to mount all filesystems listed in /etc/fstab that do not have the noauto option.
  • Gotchas: Rebooting without executing mount -a after editing /etc/fstab. If there is a typo in device names or options, the system will crash or hang on boot during the exam.
  • Verify:
findmnt --verify

(Returns SUCCESS with no parse errors)


10. Identify required and optional elements in a systemd mount unit file.

  • Command(s) / Unit Structure: Path: /etc/systemd/system/mounts-data.mount
[Unit]
Description=Mount Data Partition

[Mount]
What=/dev/disk/by-uuid/12345678-abcd-1234-abcd-123456789abc
Where=/mounts/data
Type=xfs
Options=defaults

[Install]
WantedBy=local-fs.target
  • Why: Systemd uses native .mount unit files to manage mount points. Required directives are What= (device/UUID) and Where= (absolute mount path). Type= and Options= are optional but recommended.
  • Gotchas: The filename must exactly match the target mount path hierarchy with hyphens replacing slashes (e.g., /mounts/data becomes mounts-data.mount).
  • Verify:
systemctl daemon-reload
systemctl start mounts-data.mount
systemctl status mounts-data.mount

11. Create GUID (GPT) partitions.

  • Command(s):
fdisk /dev/sdb
# Sub-commands inside fdisk:
# 'g' -> Create new empty GPT partition table
# 'n' -> Add new partition
# Accept defaults or enter size (e.g., +500M)
# 'w' -> Write table to disk and exit

Alternative using parted:

parted -s /dev/sdb mklabel gpt
parted -s /dev/sdb mkpart primary xfs 2048s 1050MB
  • Why: GPT partitioning supports modern OS installations, redundancy, and large storage devices.
  • Gotchas: Forgetting to inform the kernel of partition table updates using partprobe when editing active disks.
  • Verify:
lsblk /dev/sdb

12. Create MBR partitions.

  • Command(s):
fdisk /dev/sdb
# Sub-commands inside fdisk:
# 'o' -> Create new empty DOS/MBR partition table
# 'n' -> Add new partition (p for primary, e for extended)
# 'w' -> Write table to disk and exit
  • Why: MBR partitioning remains legacy compatible for legacy BIOS systems and legacy boot devices.
  • Gotchas: Creating more than 4 primary partitions without converting to an extended partition container.
  • Verify:
fdisk -l /dev/sdb | grep "Disklabel type: dos"

13. Identify the file used to automatically mount partitions at boot.

  • Path / Command:
/etc/fstab
  • Why: /etc/fstab contains static file system information detailing devices, mount points, file system types, mount parameters, and dump/fsck pass check orders parsed by systemd-fstab-generator at boot.
  • Gotchas: Placing invalid mount flags in field 4 will halt the system boot process.
  • Verify:
cat /etc/fstab

14. Prevent a file system from mounting automatically at boot.

  • Command(s) / Configuration: In /etc/fstab, add the noauto option in the 4th field:
UUID=12345678-abcd-1234-abcd-123456789abc /mounts/data xfs defaults,noauto 0 0
  • Why: The noauto option prevents mount -a and systemd boot generators from mounting the target file system automatically during boot.
  • Gotchas: Confusing noauto with nofail. noauto skips mounting entirely at boot; nofail attempts mounting but allows system boot to continue if the device is missing.
  • Verify:
umount /mounts/data 2>/dev/null
mount -a
findmnt /mounts/data  # (Should return empty)

15. Format a swap partition (type 82) with the appropriate file system.

  • Command(s):
mkswap /dev/sdb1
  • Why: mkswap sets up a Linux swap area on a partition or file by writing swap signatures and headers to the block device.
  • Gotchas: Attempting to activate swap space with swapon before running mkswap will result in an “Invalid argument” error.
  • Verify:
file -s /dev/sdb1 | grep "swap file"

16. Test new /etc/fstab entries safely without rebooting.

  • Command(s):
findmnt --verify
mount -a
swapon -a
  • Why: mount -a mounts all file systems defined in /etc/fstab (except noauto), and swapon -a activates all swap spaces, validating configuration accuracy in real time.
  • Gotchas: Relying solely on syntax checking; mount -a tests whether the actual target UUIDs and directories exist and match.
  • Verify:
findmnt
swapon --show

17. Identify the default file system created by mkfs without specification.

  • Command(s):
mkfs /dev/sdb1
  • Why: When executed without specifying -t <type>, the baseline mkfs wrapper binary historically defaults to building an Ext2 file system.
  • Gotchas: Never execute mkfs without explicitly declaring -t xfs or -t ext4 on an exam; raw mkfs creates un-journaled Ext2 file systems.
  • Verify:
blkid /dev/sdb1

18. Format an Ext4 partition.

  • Command(s):
mkfs.ext4 /dev/sdb1
# OR
mkfs -t ext4 /dev/sdb1
  • Why: mkfs.ext4 constructs an Ext4 (Fourth Extended) journaling file system on the specified block device.
  • Gotchas: Interrupting mkfs formatting operations before block table creation completes.
  • Verify:
blkid /dev/sdb1 | grep "ext4"

19. Find UUIDs for all devices on your computer.

  • Command(s):
blkid
# OR
lsblk -f
  • Why: Inspects block devices and prints attributes including UUID, PARTUUID, LABEL, and FSTYPE.
  • Gotchas: Copying PARTUUID (partition table identifier) instead of UUID (file system identifier) into /etc/fstab.
  • Verify:
lsblk -o NAME,UUID,FSTYPE

Lab Tasks

Task 1: Add a new disk device to your server (via virtualization software or USB).

  • Command(s):
# Scan SCSI host buses to detect newly added disks without rebooting:
for host in /sys/class/scsi_host/host*/scan; do echo "- - -" > "$host"; done
lsblk
  • Why: Scanning the SCSI subsystem forces the Linux kernel to re-enumerate storage buses and discover newly attached virtual disk drives (e.g., /dev/sdb or /dev/vdb).
  • Gotchas: Rebooting unnecessarily when hot-plug scanning can make newly attached disks immediately available.
  • Verify:
lsblk | grep -E "sdb|vdb"

Task 2: Create two partitions of 100 MiB each: one configured as swap space, the other formatted with Ext4.

  • Command(s):
# 1. Partition disk using parted non-interactively or fdisk:
parted -s /dev/sdb mklabel gpt
parted -s /dev/sdb mkpart primary linux-swap 1MiB 101MiB
parted -s /dev/sdb mkpart primary ext4 101MiB 201MiB
udevadm settle

# 2. Format swap partition:
mkswap /dev/sdb1

# 3. Format Ext4 partition:
mkfs.ext4 /dev/sdb2
  • Why:

  • parted: Sets up a clean GPT partition layout and creates two 100 MiB partitions.

  • udevadm settle: Ensures device nodes under /dev/ are populated before formatting commands run.

  • mkswap / mkfs.ext4: Writes swap headers and Ext4 file system structures to respective partitions.

  • Gotchas: Aligning partitions incorrectly by starting at offset 0 instead of 1MiB (causes alignment warnings and performance issues).

  • Verify:

lsblk -f /dev/sdb

Task 3: Configure the server to automatically mount the Ext4 partition on /mounts/data and the swap partition as swap space.

  • Command(s):
# 1. Create target mount directory:
mkdir -p /mounts/data

# 2. Extract UUIDs:
SWAP_UUID=$(blkid -s UUID -o value /dev/sdb1)
DATA_UUID=$(blkid -s UUID -o value /dev/sdb2)

# 3. Append persistent entries to /etc/fstab:
echo "UUID=${DATA_UUID} /mounts/data ext4 defaults,nofail 0 2" >> /etc/fstab
echo "UUID=${SWAP_UUID} none swap defaults,nofail 0 0" >> /etc/fstab

# 4. Mount and activate without rebooting:
mount -a
swapon -a
  • Why:

  • UUID=: Guarantees target block devices mount reliably regardless of system path changes.

  • nofail: Prevents system boot failure if the disk is unplugged or missing.

  • mount -a & swapon -a: Applies settings immediately to verify configuration validity.

  • Gotchas: Hardcoding raw device paths (e.g., /dev/sdb1) instead of UUIDs; leaving out swapon -a during testing.

  • Verify:

findmnt /mounts/data
swapon --show | grep "/dev/sdb1"

Task 4: Reboot and verify all mounts are correct. Troubleshoot any issues using essential troubleshooting skills.

  • Command(s):
# 1. Test fstab prior to reboot:
findmnt --verify

# 2. Reboot system:
reboot

# 3. Post-reboot verification:
findmnt /mounts/data
swapon --show
df -h /mounts/data
  • Why: Verification post-reboot proves that the configurations persist across kernel initializations and systemd target changes.
  • Gotchas: If the system drops into Emergency Shell during reboot:
  1. Enter root password.
  2. Remount / as read-write: mount -o remount,rw /.
  3. Inspect /etc/fstab for typos using journalctl -xb or systemctl status *.mount.
  4. Fix typos or comment out problematic lines, run systemctl daemon-reload, then reboot.
  • Verify:
findmnt /mounts/data && swapon -s

(Confirms Ext4 file system is mounted on /mounts/data and swap space is active after reboot)