More Questions from Linux

Linux swap partitions with fdisk When creating a dedicated swap partition using fdisk for Linux, which hexadecimal system ID type should you set for that partition so the kernel and tools recognize it as swap space?

Computer Science Linux Difficulty: Easy
Choose an option
  • A
    83
  • B
    82
  • C
    5
  • D
    4
  • E
    None of the above

Answer

Correct Answer: 82

Explanation

Introduction / Context:On MBR-partitioned disks, fdisk assigns a one-byte hexadecimal “system ID” to each partition. Linux tools recognize certain IDs for filesystems and special purposes. Correctly tagging a partition as swap ensures the system can format and activate it during boot or on demand.

Given Data / Assumptions:

  • We are using classic MBR-style partitioning with fdisk.
  • We want a dedicated Linux swap partition.
  • We must choose the correct hex type value.

Concept / Approach:By convention, 0x82 identifies a Linux swap partition, while 0x83 identifies a standard Linux filesystem partition (e.g., ext2/3/4, xfs when using MBR). Setting the correct ID helps initramfs and system tools like swapon/fstab recognize the partition's role.

Step-by-Step Solution:Create the partition with fdisk.Set the type with the “t” command and enter 82 for Linux swap.Write changes, then run mkswap /dev/sdXN to format it.Add an entry in /etc/fstab using UUID=… with type swap and options like defaults.

Verification / Alternative check:Use blkid to confirm type and UUID, then run swapon --show to verify activation. /proc/swaps lists active swap areas.

Why Other Options Are Wrong:83 corresponds to Linux filesystem partitions, not swap.5 is the old DOS extended partition type, not swap.4 is FAT16 <32M type in old DOS schemes, not swap.

Common Pitfalls:

  • Forgetting to run mkswap after setting the partition type.
  • Not adding the swap entry to /etc/fstab for persistence.
  • Using MBR types on GPT disks; with GPT, use partition type GUIDs and tools like parted.

Final Answer:82

Discussion & Comments
No comments yet. Be the first to comment!
Join Discussion