← All chapters · Book · Repository
Chapter 6: Filesystems and Storage Answers
Red Hat RHCSA 10 Study Companion: Getting Ready for the EX200 Exam by Andrey Markelov (May 2026).
Topics
- GPT partitioning (parted)
- XFS filesystem
- fstab configuration
- SGID permissions
- Swap files
exercise_01.sh
instructional safe: yes requires: /dev/sdb#!/bin/bash
# @type: instructional
# @requires: /dev/sdb
# @safe: yes
# Exercise 1: Use the parted command to create a new GPT partition table on a disk (e.g., /dev/sdb)
# and then create a new primary partition using 30% of the available space.
# Format this partition with the XFS file system.
#
# Task: Create GPT partition table, partition, and format with XFS.
#
# WARNING: This will erase all data on the disk. Use with caution!
echo "This script demonstrates the parted commands needed."
echo "Run: sudo parted /dev/sdb"
echo ""
echo "Commands to enter in parted:"
echo "mktable gpt - Create GPT partition table"
echo "mkpart primary xfs 0% 30% - Create partition using 30% of space"
echo "print - Display partition table"
echo "quit - Exit parted"
echo ""
echo "Then format the partition:"
echo "sudo mkfs.xfs /dev/sdb1"
exercise_02.sh
executable safe: no requires: root, /dev/sdb#!/bin/bash
# @type: executable
# @requires: root, /dev/sdb
# @safe: no
set -euo pipefail
# Exercise 2: Modify the /etc/fstab file to ensure the new XFS partition mounts automatically
# to /mnt/newxfs every time the system boots. Use the partition's UUID for the entry.
#
# Task: Create mount point, get UUID, and add entry to /etc/fstab.
# Create mount point
sudo mkdir -p /mnt/newxfs
# Get the UUID of the partition
echo "UUID of /dev/sdb1:"
sudo blkid /dev/sdb1
# Add entry to /etc/fstab
# Get the UUID from blkid output and add to fstab
UUID=$(sudo blkid -s UUID -o value /dev/sdb1)
echo "UUID=$UUID /mnt/newxfs xfs defaults 0 0" | sudo tee -a /etc/fstab
# Verify fstab syntax
sudo findmnt --verify
# Reload systemd and mount
sudo systemctl daemon-reload
sudo mount -a
echo "Partition should now be mounted at /mnt/newxfs"
exercise_03.sh
instructional safe: yes requires: /dev/sdb#!/bin/bash
# @type: instructional
# @requires: /dev/sdb
# @safe: yes
# Exercise 3: Use parted command to create a new partition with LVM type using 50% of the available space.
# Add partition to existing LVM group and extend / file system.
#
# Task: Create LVM partition, add to volume group, and extend root filesystem.
#
# WARNING: This modifies disk partitions and filesystems. Use with caution!
echo "This script demonstrates the parted and LVM commands needed."
echo ""
echo "Step 1: Create partition with parted"
echo "Run: sudo parted /dev/sdb"
echo "mkpart primary 30% 80%"
echo "set 2 lvm on"
echo "print"
echo "quit"
echo ""
echo "Step 2: Add to LVM"
echo "sudo vgextend rhel /dev/sdb2"
echo ""
echo "Step 3: Extend logical volume and filesystem"
echo "sudo lvextend -l +100%FREE /dev/rhel/root"
echo "sudo xfs_growfs /"
exercise_04.sh
executable safe: yes#!/bin/bash
# @type: executable
# @requires: none
# @safe: yes
set -euo pipefail
# Exercise 4: Use the lsblk --fs or blkid commands to list all file systems
# on your system and their corresponding UUIDs.
#
# Task: Display filesystem information for all block devices.
echo "=== Using lsblk --fs ==="
sudo lsblk --fs
echo ""
echo "=== Using blkid ==="
sudo blkid
exercise_05.sh
executable safe: no requires: root#!/bin/bash
# @type: executable
# @requires: root
# @safe: no
set -euo pipefail
# Exercise 5: Create a directory /tmp/shared_project and a group named devops.
# Set the directory's group ownership to devops and apply the SGID bit.
# Add your user to the devops group and verify that any new files you create
# in that directory inherit the devops group ownership.
#
# Task: Create directory with SGID bit, configure group ownership, and test inheritance.
# Create directory
sudo mkdir -p /tmp/shared_project
# Create group
sudo groupadd devops
# Set group ownership
sudo chgrp devops /tmp/shared_project
# Set permissions with SGID bit (2770)
sudo chmod 2770 /tmp/shared_project
# Add current user to devops group
sudo usermod -aG devops "$USER"
# Display directory permissions
ls -ld /tmp/shared_project/
# Switch to devops group context
newgrp devops << EOF
# Create a test file
touch /tmp/shared_project/testfile
# Verify group ownership
ls -l /tmp/shared_project/testfile
EOF
echo ""
echo "Verification complete. The testfile should have devops group ownership."
exercise_06.sh
executable safe: no requires: root#!/bin/bash
# @type: executable
# @requires: root
# @safe: no
set -euo pipefail
# Exercise 6: Create a 1 Gb file at /tmp/swapfile using dd.
# Use the mkswap command to format the file as a swap area.
# Activate the swap file with the swapon command and verify the new total swap size with free -h.
#
# Task: Create and activate a swap file.
# Create 1 GB swap file
sudo dd if=/dev/zero of=/tmp/swapfile bs=1M count=1024
# Set proper permissions (important for security)
sudo chmod 600 /tmp/swapfile
# Format as swap
sudo mkswap /tmp/swapfile
# Activate swap
sudo swapon /tmp/swapfile
# Verify swap is active
free -h
echo ""
echo "Swap file created and activated. Use 'sudo swapoff /tmp/swapfile' to deactivate."