RH134 Ch 5: Partitions, File Systems and Swap
Before a disk can hold files it needs a partition table, partitions and file systems, and the system must know where to mount them at boot.
Partition tables. GPT is the modern choice (up to 128 partitions, disks over 2 TiB); MBR (msdos) is the legacy one. parted does both and works non-interactively, which makes it script-friendly:
bash parted /dev/vdb mklabel gpt parted /dev/vdb mkpart data xfs 1MiB 1025MiB parted /dev/vdb print udevadm settle wait for /dev/vdb1 to appear
fdisk and gdisk are interactive alternatives. Starting at 1MiB keeps partitions aligned. Never repartition a disk that already holds data you were asked to keep: add new partitions in free space.
File systems. mkfs.xfs (default on RHEL; can grow, never shrink), mkfs.ext4 (can grow and shrink offline) and mkfs.vfat (for exchange with other systems). Labels are set with -L (XFS/ext4) or -n (VFAT). lsblk -f and blkid show type, label and UUID.
Persistent mounts. Device names can change between boots, so /etc/fstab should name file systems by UUID or label:
UUID=7f1d… /scratch ext4 defaults 0 0 LABEL=ARCHIVE /archive xfs defaults 0 0 UUID=1A2B-3C4D /transfer vfat defaults 0 0
After editing, run systemctl daemon-reload and mount -a; an error now is far better than a system that stops at boot.
Swap. Create a partition (type linux-swap), then mkswap /dev/vdb4, add UUID=… none swap defaults 0 0 to fstab and activate with swapon -a. Check with swapon --show or free -h. Priority can be set with pri= in the options.
Common exam mistakes - Mounting by hand and forgetting fstab, so the mount disappears after reboot. - Typos in fstab — always test with mount -a before rebooting. - Using /dev/vdb1 when the task says UUID or label. - Making XFS smaller than 300 MiB, or formatting the whole disk instead of the partition.