Managing Storage

Nov 12, 2025

References:

The Basics

Listing block devices

lsblk

Creating partitions

fdisk {device}

Creating filesystems

mkfs.xfs /dev/device
mkfs.ext4 /dev/device
mkfs.vfat /dev/device

Mounting and unmounting partitions

mount /dev/partition /mnt/path
umount /mnt/path # unmount a device

Finding mounts

mount # shows all mounted filesystems, including kernel mounts
findmnt # shows all mounts in tree-like structure
lsblk

Mounting partitions automatically

To mount a filesystem automatically, add entry to /etc/fstab.

  • Always create a backup before editing
  • Always verify correctness before rebooting (mount -a or findmnt --verify)
device mount-path filesystem defaults 0 0

The last two entries are legacy options. Rarely used on modern systems.

If the fstab is broken (or something else), you may not be able to access a console if there is no root password. In this case, edit the GRUB boot command by pressing e at the boot menu. Remove rhgb quiet from the end of the line starting with linux and add init=/bin/bash. The filesystem will be mounted in read-only mode. Use mount -o remount,rw / and make the necessary changes. Modified files will get an incorrect SELinux label. Use touch /.autorelabel to ensure labeling is corrected on the next boot and then echo s > /proc/sysrq-trigger to trigger an emergency sync before rebooting with echo b > /proc/sysrq-trigger. This procedure is extremely important for the exam.

Using UUID and labels

Block device names (eg /dev/sdb) are subject to change, so use UUIDs or labels in the fstab.

Print block device attributes

blkid

Set a label for ext filesystem

tune2fs -L

Set a label for XFS filesystem

xfs_admin -L

Set a label while creating a filesystem

mkfs.* -L

Systemd mounts

Example systemd mount: /etc/systemd/system/files.mount

[Unit]
Documentation=man:fstab(5) man:systemd-fstab-generator(8)

[Mount]
What=/dev/disk/by-uuid/{UUID}
Where=/mnt/path
Type=ext4
Options=nofail

[Install]
WantedBy=multi-user.target

Examples copied from /run/systemd/generator will be missing the Install section.

Creating a swap partition

Create swap space from block device

  • Set partition type to linux-swap
  • Use mkswap to create the swap filesystem
  • Activate using swapon

Knowledge check

  1. What type of device would /dev/sdx commonly be?
  2. What type of device would /dev/vdx commonly be?
  3. Where does lsblk get its information from?
  4. Which filesystem offers multi-OS support?
  5. Which filesystem is used for a UEFI boot partition?
  6. Which filesystem is the default for RHEL?
  7. How can you view the systemd mounts?
Answers
  1. SCSI, SATA, and disks connected via USB
  2. KVM virtual machines
  3. The kernel partition table: /proc/partitions
  4. vfat
  5. vfat
  6. XFS
  7. Cat the files in /run/systemd/generator

Lab Exercise

  • Create a partition with a size of 1GiB. Format it with ext4, and mount it persistently on /mounts/files using its UUID
  • Create a 512 MiB swap partition and mount it persistently
  • Create another 1G partition of type Linux Filesystem. Format it with XFS and intentionally put an incorrect UUID number in the fstab with the default mount settings. Reboot the VM and recover.

- Clint Jordan