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
fdiskcannot edit GPT disks on modern RHEL versions. (Correction: Utilityfdiskin 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
fdiskonly works on MBR;fdiskdefaults to GPT if the disk has a GPT label or is initialized withg. -
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
mkswapwithout setting the partition type code infdisk/gdiskworks, 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/sdain exam scripts or/etc/fstabwhen the KVM exam environment uses/dev/vdaor/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; mirrorsfdiskcommand 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:
partedwrites changes to disk immediately without an explicit “write/save” step, whereasfdisk/gdiskrequire pressingwto 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/vdb1in/etc/fstabinstead ofUUID=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/fstabwithUUID=ensures persistent mounting at system startup regardless of block device identifier shifts. - Gotchas: Syntax errors or typos in UUID strings in
/etc/fstabwill 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 --verifychecks/etc/fstabfor syntax errors, missing mount points, or duplicate entries.mount -aattempts to mount all filesystems listed in/etc/fstabthat do not have thenoautooption. - Gotchas: Rebooting without executing
mount -aafter 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
.mountunit files to manage mount points. Required directives areWhat=(device/UUID) andWhere=(absolute mount path).Type=andOptions=are optional but recommended. - Gotchas: The filename must exactly match the target mount path hierarchy with hyphens replacing slashes (e.g.,
/mounts/databecomesmounts-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
partprobewhen 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/fstabcontains static file system information detailing devices, mount points, file system types, mount parameters, and dump/fsck pass check orders parsed bysystemd-fstab-generatorat 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 thenoautooption in the 4th field:
UUID=12345678-abcd-1234-abcd-123456789abc /mounts/data xfs defaults,noauto 0 0
- Why: The
noautooption preventsmount -aand systemd boot generators from mounting the target file system automatically during boot. - Gotchas: Confusing
noautowithnofail.noautoskips mounting entirely at boot;nofailattempts 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:
mkswapsets 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
swaponbefore runningmkswapwill 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 -amounts all file systems defined in/etc/fstab(exceptnoauto), andswapon -aactivates all swap spaces, validating configuration accuracy in real time. - Gotchas: Relying solely on syntax checking;
mount -atests 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 baselinemkfswrapper binary historically defaults to building an Ext2 file system. - Gotchas: Never execute
mkfswithout explicitly declaring-t xfsor-t ext4on an exam; rawmkfscreates 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.ext4constructs an Ext4 (Fourth Extended) journaling file system on the specified block device. - Gotchas: Interrupting
mkfsformatting 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, andFSTYPE. - Gotchas: Copying
PARTUUID(partition table identifier) instead ofUUID(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/sdbor/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
0instead of1MiB(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 outswapon -aduring 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:
- Enter root password.
- Remount
/as read-write:mount -o remount,rw /. - Inspect
/etc/fstabfor typos usingjournalctl -xborsystemctl status *.mount. - Fix typos or comment out problematic lines, run
systemctl daemon-reload, thenreboot.
- Verify:
findmnt /mounts/data && swapon -s
(Confirms Ext4 file system is mounted on /mounts/data and swap space is active after reboot)