LinuxCommandLibrary

gdisk

Manage GPT (GUID Partition Table) disks

SYNOPSIS

gdisk [-l|--list-partitions] [-h|--help] [-v|--version] device

PARAMETERS

device
    The disk device (e.g., /dev/sda, /dev/nvme0n1) on which to operate. This is usually the primary argument.

-l, --list-partitions
    Lists the partition table for the specified device and then exits, without entering the interactive mode.

-h, --help
    Displays a brief help message showing command-line options and then exits.

-v, --version
    Prints the program's version number and exits.

DESCRIPTION

gdisk is a powerful, interactive utility designed for creating, manipulating, and managing GUID Partition Table (GPT) disk partition tables. It serves as a modern alternative to the traditional fdisk command, which primarily focuses on Master Boot Record (MBR) partitioning schemes. With its intuitive, menu-driven text interface, gdisk allows users to perform various partitioning tasks such as creating new partitions, deleting existing ones, changing partition types, resizing partitions, and setting partition attributes.

Beyond basic partitioning, gdisk offers advanced features like converting MBR or Apple Partition Map (APM) disks to GPT, backing up and restoring partition tables, and verifying partition integrity. It is part of the gptfdisk utility suite, which also includes sgdisk for scripting and non-interactive operations. gdisk is essential for managing modern storage devices that typically use GPT, supporting larger disk sizes and more partitions than MBR.

CAVEATS

Root Privileges: gdisk requires root (sudo) privileges to operate on disk devices.
Data Loss Risk: Incorrect use of gdisk, especially when writing changes to disk, can lead to severe data loss. Always back up important data before making partitioning changes.
Interactive Only: Most operations are performed within the interactive menu. Command-line options are limited to listing, help, and version information.
GPT Focus: While it can convert MBR to GPT, its primary design and best use case are for disks already using or intended for GPT. For MBR disks, fdisk might be more appropriate.

INTERACTIVE MODE

Upon launching gdisk with a device (e.g., gdisk /dev/sda), it enters an interactive, menu-driven interface. Users type single-character commands followed by Enter to perform actions. Some common interactive commands include:
p: Print the partition table.
n: Create a new partition.
d: Delete a partition.
w: Write partition table to disk and exit (CAUTION: permanent changes!).
q: Quit without saving changes.
r: Recovery and transformation options (e.g., backup, restore, convert MBR to GPT).

GPT ADVANTAGES

GPT offers several advantages over MBR, including support for disk sizes larger than 2TB, virtually unlimited partitions (limited by OS to typically 128), CRC checksums for partition table integrity, and redundant primary/backup partition tables.

HISTORY

gdisk was developed by Roderick W. Smith as part of the gptfdisk project, with its initial public release around 2009. The primary motivation for its creation was the increasing adoption of GUID Partition Table (GPT) as a successor to the older Master Boot Record (MBR) partitioning scheme, especially with the proliferation of larger hard drives (beyond 2TB) and the advent of UEFI firmware. gdisk aimed to provide a familiar, fdisk-like interactive text interface specifically tailored for GPT management, addressing a gap in existing Linux partitioning tools at the time. Its development ensured robust and user-friendly support for GPT on Linux systems.

SEE ALSO

fdisk(8), parted(8), sgdisk(8), mkfs(8), mount(8)

Copied to clipboard