Red Hat Certified System Administrator RHCSA · Free Practice Question Easy

Question 25

On ServerB, use /dev/sdb to create a new 1G swap partition that takes effect automatically at boot start.

  • A

    Pass

  • B

    Fail

Reveal correct answer

Correct answer: A

Explanation

Step-by-Step Guide

  1. Check Current Memory and Swap Usage

    • Command:

    • Explanation:
      This command displays memory and swap usage in megabytes, allowing you to check existing swap space. Monitoring free -m before and after setup helps verify the addition of new swap space.

  1. Open the fdisk Utility to Partition /dev/sdb

    • Command:

    • Explanation:
      fdisk is a command-line utility for disk partitioning. Opening it with /dev/sdb allows you to create, modify, and manage partitions on that specific disk.

  2. Create a New Partition in fdisk

    • Follow these fdisk prompts:

      • m: Display help (optional).

      • n: Start creating a new partition.

      • p: Specify a primary partition.

      • 4 (or press Enter): Accept the default partition number or specify 4.

      • Press Enter: Accept the default first sector.

      • +1G: Define the size of the partition (1GB).

    • Explanation:
      Creating a 1GB partition here ensures the new swap space is ready to be configured and formatted.

  3. Set Partition Type to Linux Swap

    • Command sequence in fdisk:

      • t: Change the partition type.

      • 4 (partition number): Choose the partition you created.

      • l: List available partition types.

      • 82: Select 82 for Linux Swap.

      • Explanation: Setting the type as Linux Swap is crucial for the system to recognize and use it as swap space.

  4. Save Changes and Exit fdisk

    • Command in fdisk:

    • Explanation:
      The w command writes the changes to the disk and exits fdisk. At this point, the new partition is created but not yet formatted or mounted as swap.

  1. Inform the Kernel of Partition Changes

    • Command:

    • Explanation:
      partprobe notifies the kernel of the new partition table without requiring a reboot. This ensures the kernel recognizes the new partition immediately.

  1. Format the Partition as Swap

    • Command:

    • Explanation:
      This command formats /dev/sdb4 as swap space, making it ready for use as a swap partition. mkswap assigns a unique identifier (UUID) to the swap partition.

  2. Get the UUID of the New Swap Partition

    • Command:

    • Explanation:
      The UUID is a unique identifier for the partition. Using the UUID instead of the device path (/dev/sdb4) in /etc/fstab ensures that the system consistently recognizes the swap partition, even if device names change.

  1. Add the Swap Partition to /etc/fstab

    • Command:

    • Entry to Add in /etc/fstab:

    • Explanation:
      Adding the swap partition entry in /etc/fstab makes it persistent, enabling the swap space to be activated automatically at boot. Replace <UUID> with the actual UUID from the blkid command.

  1. Activate the Swap Partition Immediately

  • Command:

  • Explanation:
    swapon activates the newly created swap partition, making it available for immediate use without needing a reboot.

  1. Verify the New Swap Space

  • Commands:

  • Explanation:
    These commands show the active swap space, confirming that the new 1GB swap partition is in use. free -m shows memory and swap usage in megabytes, while swapon --show provides detailed information on all active swap areas.

  1. Check Block Device Information (Optional)

  • Command:

  • Explanation:
    lsblk displays all block devices, showing the swap partition with its size, type, and mount point. This visual confirmation ensures the partition is correctly set up and recognized by the system.

Additional Notes and Tips:

  • Partprobe Utility:
    partprobe helps avoid the need for a system reboot after partition changes. This is especially useful when creating or modifying partitions in environments where downtime is minimized.

  • UUID vs. Device Path in /etc/fstab:
    Using the UUID (from blkid) instead of the device path (/dev/sdb4) ensures the system recognizes the swap partition reliably, even if device names change due to hardware reordering.

  • Exam Tip:
    Practice the complete process of creating, formatting, and activating swap partitions. Ensure familiarity with commands like fdisk, mkswap, swapon, and fstab entries, as these are commonly tested.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need