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:
lsblkβ Lists block devices and partitions in a tree format:
lsblk
- Shows disks (
/dev/sda,/dev/sdb) and their partitions (/dev/sda1,/dev/sda2).
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
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
- Start
partedon your disk:
sudo parted /dev/sda
- Create a new partition table (if needed):
mklabel gpt
gpttells the system to use the GPT partition table format.
- 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 partition10GiBβ End of partition
- Exit
parted:
quit
Using gdisk
- Start
gdiskon the disk:
sudo gdisk /dev/sda
- 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.,
8300for Linux filesystem)
- 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 1removes partition number 1.
Using gdisk
- Start
gdisk:
sudo gdisk /dev/sda
- Press
dβ select partition number β press Enter - 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
- Know commands:
lsblk,parted,gdisk. - Know GPT vs MBR: GPT allows more partitions and uses GUIDs.
- Understand partition types: Linux filesystems, swap, EFI system.
- Start and end points: You can define exact sizes in MiB/GiB.
- Practical: Be able to list, create, and delete partitions in a Linux environment.
β Summary Table
| Task | Command Example | Notes |
|---|---|---|
| List partitions | lsblk / sudo parted /dev/sda print | Shows existing partitions and sizes |
| Create GPT table | sudo parted /dev/sda mklabel gpt | Only if disk is empty or you want to reformat |
| Create partition | sudo parted /dev/sda mkpart primary ext4 1MiB 10GiB | Creates a new ext4 partition |
| Delete partition | sudo parted /dev/sda rm 1 | Deletes partition 1 (careful!) |
| GPT-specific creation | sudo gdisk /dev/sda β n β w | Alternative tool, handles GUIDs |
This knowledge ensures you can handle any GPT disk partition task on a Linux system for the DEVASC exam.
