List, create, and delete partitions on GPT disks

5.1 List, create, and delete partitions on GPT disks

πŸ“˜Red Hat Certified System Administrator (RHCSA – EX200)


In IT systems, storage is divided into disks and partitions. A GPT disk (GUID Partition Table) is a modern way to organize data on a hard drive or SSD, especially for disks larger than 2 TB. GPT is part of the UEFI standard and is replacing the older MBR (Master Boot Record) system.


1. Understanding GPT Disks

  • GPT (GUID Partition Table) uses globally unique identifiers (GUIDs) to identify partitions.
  • A GPT disk can have up to 128 partitions by default, without needing β€œextended” or β€œlogical” partitions like MBR.
  • GPT stores backup partition tables at the start and end of the disk for recovery.
  • Each partition has a unique GUID and can store a specific type of data (e.g., Linux filesystem, swap, EFI system partition).

Key Points for Exam:

  • Recognize the difference between GPT vs MBR.
  • Know that GPT is required for UEFI boot.
  • You should know how to list, create, and delete partitions using Linux command-line tools.

2. Listing Partitions on GPT Disks

Before creating or deleting partitions, you must know what’s on the disk.

Common commands:

  1. lsblk – Lists block devices and partitions in a tree format:
lsblk
  • Shows disks (/dev/sda, /dev/sdb) and their partitions (/dev/sda1, /dev/sda2).
  1. parted – A tool for GPT and MBR disks:
sudo parted /dev/sda print
  • Displays:
    • Disk size
    • Partition numbers
    • File system type
    • Flags (like bootable)
    • Partition start and end points
  1. gdisk – GPT-specific tool:
sudo gdisk -l /dev/sda
  • Shows partition table with GUIDs and type codes.

Tip for exam: Always check the disk you want to modify to avoid deleting important data.


3. Creating Partitions on GPT Disks

To create a new partition:

Using parted

  1. Start parted on your disk:
sudo parted /dev/sda
  1. Create a new partition table (if needed):
mklabel gpt
  • gpt tells the system to use the GPT partition table format.
  1. Create a new partition:
mkpart primary ext4 1MiB 10GiB
  • primary – Partition type (GPT doesn’t need extended/logical distinction)
  • ext4 – File system type (can also use xfs, swap, etc.)
  • 1MiB – Start of partition
  • 10GiB – End of partition
  1. Exit parted:
quit

Using gdisk

  1. Start gdisk on the disk:
sudo gdisk /dev/sda
  1. Press:
  • n β†’ New partition
  • Enter partition number (or press Enter for default)
  • Enter start and end sectors (or press Enter for defaults)
  • Choose partition type code (e.g., 8300 for Linux filesystem)
  1. Write changes:
w
  • This saves the new partition to the disk.

4. Deleting Partitions on GPT Disks

Using parted

sudo parted /dev/sda
rm 1
quit
  • rm 1 removes partition number 1.

Using gdisk

  1. Start gdisk:
sudo gdisk /dev/sda
  1. Press d β†’ select partition number β†’ press Enter
  2. Press w β†’ write changes

Important: Deleting a partition removes all data in it. Always double-check which partition you’re deleting.


5. Exam Tips for DEVASC

  1. Know commands: lsblk, parted, gdisk.
  2. Know GPT vs MBR: GPT allows more partitions and uses GUIDs.
  3. Understand partition types: Linux filesystems, swap, EFI system.
  4. Start and end points: You can define exact sizes in MiB/GiB.
  5. Practical: Be able to list, create, and delete partitions in a Linux environment.

βœ… Summary Table

TaskCommand ExampleNotes
List partitionslsblk / sudo parted /dev/sda printShows existing partitions and sizes
Create GPT tablesudo parted /dev/sda mklabel gptOnly if disk is empty or you want to reformat
Create partitionsudo parted /dev/sda mkpart primary ext4 1MiB 10GiBCreates a new ext4 partition
Delete partitionsudo parted /dev/sda rm 1Deletes partition 1 (careful!)
GPT-specific creationsudo gdisk /dev/sda β†’ n β†’ wAlternative tool, handles GUIDs

This knowledge ensures you can handle any GPT disk partition task on a Linux system for the DEVASC exam.

Buy Me a Coffee